mapIndexedAndLast<R> method

Iterable<R> mapIndexedAndLast<R>(
  1. R convert(
    1. int index,
    2. T item,
    3. bool isLast
    )
)

Maps each element and its index to a new value. This is similar to mapIndexed but also tells you which item is the last.

Implementation

Iterable<R> mapIndexedAndLast<R>(R Function(int index, T item, bool isLast) convert) sync* {
  var index = 0;
  int _length = length; // In case length is not efficient.
  for (var item in this) {
    yield convert(index++, item, index == _length);
  }
}