mapIndexed<E> method

Iterable<E> mapIndexed<E>(
  1. E f(
    1. int index,
    2. T item
    )
)

map() that also gives the index. items.mapIndexed((i, e) => "$i: $e")

Implementation

Iterable<E> mapIndexed<E>(E Function(int index, T item) f) sync* {
  int index = 0;
  for (final T item in this) {
    yield f(index++, item);
  }
}