how to do a for loop in ruby code example
Example 1: ruby for loop
for i in 0..2 do
print(i)
end
# => 0
# => 1
# => 2
Example 2: ruby for loop
for element in array do
element.do_stuff
end
for i in 0..2 do
print(i)
end
# => 0
# => 1
# => 2
for element in array do
element.do_stuff
end