zip<S> method

List<$<T, S>> zip<S>(
  1. Iterable<S> t
)

zip corresponding values with values from another iterable. If one iterable is shorter than the other, it generates iterable of shorter length.

example


[1,2,3,4,5].zip('a','b','c') // => [(1,'a'),(2,'b'),(3,'c')]

Implementation

List<$<T, S>> zip<S>(Iterable<S> t) {
  if (t.length > length) {
    return List<$<T, S>>.generate(
        length, (i) => $(elementAt(i), t.elementAt(i)));
  } else {
    return List<$<T, S>>.generate(
        t.length, (i) => $(elementAt(i), t.elementAt(i)));
  }
}