fun <T, R> Iterable<T>.zipWithNull(other: Iterable<R>): List<Pair<T?, R?>> = buildList {
val first = this@zipWithNull.iterator()
val second = other.iterator()
while (first.hasNext() || second.hasNext()) {
val left = if (first.hasNext()) first.next() else null
val right = if (second.hasNext()) second.next() else null
add(left to right)
}
}
s
simon.vergauwen
12/14/2022, 7:39 AM
There has been a proposal for a more universal function like this for a long time.