flatMapWithIndex<B> method

Iterable<B> flatMapWithIndex<B>(
  1. Iterable<B> toElements(
    1. T t,
    2. int index
    )
)

Same as flatMap (extend) but provides also the index of each mapped element in the mapping function (toElements).

Implementation

Iterable<B> flatMapWithIndex<B>(
  Iterable<B> Function(T t, int index) toElements,
) sync* {
  var index = 0;
  for (var value in this) {
    yield* toElements(value, index);
    index += 1;
  }
}