How to get index in a loop?

I want to find out the current index while i am in the each loop. how do i do so?

use

10.times do |index|
  puts "loop index is",index
end

alternatively use tick and look

10.times do
  tick
  puts "loop index is",look
end
1 Like