mapIndexed<R> method

Iterable<R> mapIndexed<R>(
  1. R f(
    1. int index,
    2. T element
    )
)

Behaves like the map function but also exposes the index of the current element.

Implementation

Iterable<R> mapIndexed<R>(R Function(int index, T element) f) sync* {
  final iter = iterator;
  int index = 0;
  while (iter.moveNext()) {
    yield f(index++, iter.current);
  }
}