mapIndexed<R> method

Iterable<R> mapIndexed<R>(
  1. R convert(
    1. int index,
    2. E element
    )
)

Maps each element together with its index.

Example:

['a', 'b'].mapIndexed((i, v) => '$i:$v'); // ['0:a', '1:b']

Implementation

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