Is there a way to pass an array to a function that...
# announcements
k
Is there a way to pass an array to a function that takes a vararg parameter? The spread operator passes a copy of the array, not the array itself. I encountered this problem when reading the docs of `Arrays.asList`:
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.)
But it looks like using this property is not possible from Kotlin since you can't pass the real array.
m
fun foo(vararg items: Array<Type>) May be this should work.
d
That's an "array of arrays".
m
Oh sorry.
s
I dont think you can in pure Kotlin and I can see why. I think you have to go through a java function to get the desired result.