End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Enumerator::Lazy#_enumerable_with_index
e.with_index(offset = 0) {|(*args), idx| ... }
e.with_index(offset = 0)
enumerator.c
View on GitHub ↗
static VALUE
enumerator_with_index(int argc, VALUE *argv, VALUE obj)
{
VALUE memo;
rb_check_arity(argc, 0, 1);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size);
memo = (!argc || NIL_P(memo = argv[0])) ? INT2FIX(0) : rb_to_int(memo);
return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0));
}
Iterates the given block for each element with an index, which starts from offset. If no block is given, returns a new Enumerator that includes the index, starting from offset
offset-
the starting index to use
See also
#_enumerable_uniq
#_enumerable_zip
#_enumerable_take_while
#enum_for
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.0