Loops/For with a specified step: Difference between revisions
Content added Content deleted
(Add Plain English) |
(→{{header|Ruby}}: add sample using named arguments) |
||
Line 2,377: | Line 2,377: | ||
or: |
or: |
||
<syntaxhighlight lang="ruby">for n in (2..8).step(2) |
<syntaxhighlight lang="ruby">for n in (2..8).step(2) |
||
print "#{n}, " |
|||
end |
|||
puts "who do we appreciate?"</syntaxhighlight> |
|||
or: |
|||
<syntaxhighlight lang="ruby">for n in 2.step(by: 2, to: 8) |
|||
print "#{n}, " |
print "#{n}, " |
||
end |
end |