07-18-2023, 02:15 PM
> **Possible Duplicate:**
> [Automatic counter in Ruby for each?](
<!-- End of automatically inserted text -->
I want to find out the current index while i am in the each loop. how do i do so?
X=[1,2,3]
X.each do |p|
puts "current index..."
end
> [Automatic counter in Ruby for each?](
[To see links please register here]
)<!-- End of automatically inserted text -->
I want to find out the current index while i am in the each loop. how do i do so?
X=[1,2,3]
X.each do |p|
puts "current index..."
end