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) }
Written by Sergey Lukjanov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#kotlin
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#