mapIndexed<TResult> method

Iterable<TResult> mapIndexed<TResult>(
  1. TResult toElement(
    1. TValue,
    2. int
    )
)

Returns an Iterable containing the results of all elements processed by the toElement function.

This method works like map but provides the toElement function with the elements index as second argument.

Implementation

Iterable<TResult> mapIndexed<TResult>(
    TResult Function(TValue, int) toElement) sync* {
  var i = 0;
  for (final e in this) {
    yield toElement(e, i++);
  }
}