indexed method

  1. @lazy
  2. @useResult
Iterable<(int, E)> indexed()

Returns a lazy iterable with records that contain an iteration index and element.

This function is non-deterministic when this iterable is unordered, i.e. HashSet.

['a', 'b', 'c'].indexed(); // [(1, 'a'), (2, 'b'), (3, 'c')]

Implementation

@lazy @useResult Iterable<(int index, E element)> indexed() sync* {
  var count = 0;
  for (final element in this) {
    yield (count++, element);
  }
}