instance method
Enumerator#with_index
(?::Integer offset) { (Elem arg0, ::Integer arg1) -> untyped } -> Return
(?::Integer offset) -> ::Enumerator[[ Elem, ::Integer ], Return]
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