zip method

Iterable<List> zip(
  1. Iterable other
)

Zips this iterable with other into an iterable of Lists of length 2.

The resulting iterable has the length of the shorter input. Excess elements from the longer iterable are silently dropped.

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

Implementation

Iterable<List<dynamic>> zip(Iterable<dynamic> other) sync* {
  final a = iterator;
  final b = other.iterator;
  while (a.moveNext() && b.moveNext()) {
    yield [a.current, b.current];
  }
}