Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Enumerator#each_with_index

e.each_with_index {|(*args), idx| ... }
e.each_with_index

Same as Enumerator#with_index(0), i.e. there is no starting offset.

If no block is given, a new Enumerator is returned that includes the index.

See also #each #each_with_object #+ #feed also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0