Iterate With An Offset Index
Last updated
Was this helpful?
Last updated
Was this helpful?
You can iterate over a collection of items with the method. If you want to know the index of each item as you go, you can use the variant.
The initial index will always be 0
when using #each_with_index
.
What about if you want the index value to be offset by some number?
You can use the method on an enumerator. It optionally takes an offset
argument.