mapIndex<T> method

Iterable<T> mapIndex<T>(
  1. MapIndexedValue<E, T> toElement
)

Create a new iterable by passing each element and index to the callback.

Example: if we have ['a', 'b', 'c'], then the callback is called with ('a', 0), ('b', 1), then ('c', 2).

Returns a new lazy iterable with elements that are created by calling toElement on each element of this Iterable in iteration order with a generated index.

See Iterable.map for caveats about the lazy iterable.

Implementation

Iterable<T> mapIndex<T>(MapIndexedValue<E, T> toElement) =>
    enumerate(this).map((e) => toElement(e.value, e.index));