Last Updated: March 22, 2018
·
275
· frostman

Multi-declarations

Create multiple variables at once.

val (a, b) = aAndB
println(a) // compiled to: aAndB.component1()
println(b) // compiled to: aAndB.component2()

It's working for Map.Entry (key-value) and collections (idx-value) too.

for ((a, b) in collection) { doSmth(a, b) }