Syntax for a for loop in ruby

array.each do |element|
  element.do_stuff
end

or

for element in array do
  element.do_stuff
end

If you need index, you can use this:

array.each_with_index do |element,index|
  element.do_stuff(index)
end

limit = array.length;
for counter in 0..limit
 --- make some actions ---
end

the other way to do that is the following

3.times do |n|
  puts n;
end

thats will print 0, 1, 2, so could be used like array iterator also

Think that variant better fit to the author's needs