Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin zipAll alternative

Tags:

kotlin

scala

Does Kotlin have a function like .zipAll in Scala?

In Scala I can sum two array with different length using the zipAll function.

Scala:

val arrA = Array(1,2,3)
val arrB = Array(4, 5)
arrA.zipAll(arrB, 0, 0).map(x => x._1 + x._2)

Or what is the correct way to do this in Kotlin?

like image 972
Oleg Avatar asked Jul 06 '16 20:07

Oleg


1 Answers

There is no in-build analog in Kotlin 1.0. It might be a good idea to add it into the stdlib. Feel free to file an issue on the YouTrack

like image 160
voddan Avatar answered Sep 21 '22 22:09

voddan