zip<T> method

Iterable<Pair<E, T>> zip<T>(
  1. Iterable<T> other
)

Returns a Iterable of pairs built from the elements of this collection and other collection with the same index. The returned Iterable has length of the shortest collection.

Implementation

Iterable<Pair<E, T>> zip<T>(Iterable<T> other) {
  final iter1 = iterator;
  final iter2 = other.iterator;

  return Iterable.generate(
    min(length, other.length),
    (index) => Pair((iter1..moveNext()).current, (iter2..moveNext()).current),
  );
}