mg6maciej
03/10/2017, 4:00 PMreturn stack(*toTypedArray())
mg6maciej
03/10/2017, 4:00 PMdanko9
03/10/2017, 4:01 PMdanko9
03/10/2017, 4:01 PMdanko9
03/10/2017, 4:04 PMtjb
03/10/2017, 4:08 PM*
does? i am new to Kotlin and curious. Or perhaps can you point everyone in the right direction in the docs for this?tjb
03/10/2017, 4:08 PMmg6maciej
03/10/2017, 4:09 PMmg6maciej
03/10/2017, 4:09 PMRuckus
03/10/2017, 4:10 PMmg6maciej
03/10/2017, 4:10 PMval list = asList(-1, 0, *a, 4)
. I wouldn't think of this, but it's quite useful.danko9
03/10/2017, 4:11 PMdanko9
03/10/2017, 4:11 PMmg6maciej
03/10/2017, 4:11 PMkevinmost
03/10/2017, 4:11 PM*a.toTypedArray()
Ruckus
03/10/2017, 4:12 PMmg6maciej
03/10/2017, 4:12 PMtjb
03/10/2017, 4:12 PMdanko9
03/10/2017, 4:14 PMdanko9
03/10/2017, 4:15 PMdanko9
03/10/2017, 4:15 PMdanko9
03/10/2017, 4:17 PMdanko9
03/10/2017, 4:17 PMRuckus
03/10/2017, 4:19 PMRuckus
03/10/2017, 4:20 PMRuckus
03/10/2017, 4:25 PMSpread operator always copies an array, so that neither the function nor its caller are required to make defensive copies of the array.
It might be possible for the compiler to optimize such copying away, for example when one vararg function passes its array to another vararg function and doesn't use it itself after, however such optimization has not been baked yet.https://discuss.kotlinlang.org/t/hidden-allocations-when-using-vararg-and-spread-operator/1640
uli
03/10/2017, 4:47 PMIt looks like there's currently no way to modify elements of array passed as vararg...
miha-x64
03/10/2017, 4:54 PMuli
03/10/2017, 4:54 PMuli
03/10/2017, 5:04 PM