indexed property

  1. @lazy
  2. @useResult
Iterable<(int, E)> get 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)> get indexed sync* {
  var count = 0;
  for (final element in this) {
    yield (count++, element);
  }
}