How to get index in a loop?


#1

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


#2

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