Kotlin supports destructuring declarations:
val (a, b) = Pair(1,2)
This is similar to the unpacked unboxing of Python:
a, b = (1, 2)
Python also has a splat / spread statement that allows you to perform a similar operation with function arguments:
def f(a, b): pass pair = (1,2) f(*pair)
Does kotlin have a similar ability? Obviously, you can unzip the structure manually:
f(pair.component1(), pair.component2())
But this is awkward. Is there any way to make this more elegant? I donβt see anything in the related documents .
source share