In Ruby, you can iterate over a list (or an array) using different types of loops. Here are a few examples:
each
method:main.rb59 chars5 lines
for
loop:main.rb59 chars5 lines
while
loop:main.rb82 chars7 lines
All of the above loops will output the same result:
main.rb10 chars6 lines
You can choose the loop that suits your needs depending on the situation.
gistlibby LogSnag