Skip to content
instance method

Enumerator::Lazy#with_index

(?::Integer offset) { (Elem arg0, ::Integer arg1) -> untyped } -> Return
(?::Integer offset) -> ::Enumerator[[ Elem, ::Integer ], Return]
lazy.with_index(offset = 0) {|(*args), idx| block }
lazy.with_index(offset = 0)

If a block is given, returns a lazy enumerator that will iterate over the given block for each element with an index, which starts from offset, and returns a lazy enumerator that yields the same values (without the index).

If a block is not given, returns a new lazy enumerator that includes the index, starting from offset.

offset

the starting index to use

See Enumerator#with_index.

See also #uniq #zip #to_enum also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0