zip<U> method

List<Pair<T, U>> zip<U>(
  1. List<U> other
)

Zips this list with other into a list of Pairs. Stops at the shorter list.

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

Implementation

List<Pair<T, U>> zip<U>(List<U> other) {
  final len = math.min(length, other.length);
  return List.generate(len, (i) => Pair(this[i], other[i]));
}