pairUp method
- List<
T> other
Pairs up the elements of this list with the elements of the other
list.
Returns a new list of tuples, where each tuple contains two elements:
the corresponding element from this list and the corresponding element from the other
list.
If one of the lists is shorter than the other, the missing elements are paired with null.
Implementation
List<(T?, T?)> pairUp(List<T> other) {
var l = toList();
return pairUpIndexes(other).map((e) {
if (e.$1 == -1) {
return (null, other[e.$2]);
} else if (e.$2 == -1) {
return (l[e.$1], null);
} else {
return (l[e.$1], other[e.$2]);
}
}).toList();
}