I've recently tried the following code in kotlinc, command line environment.
var greet = Pair("Hello", "World")
val (word1, word2) = greet
Outputting word1
and word2
in console outputs the below message
>>> word1
error: unresolved reference: word1
word1
^
I'm not sure if de-structuring is being removed from the latest version of kotlin. Currently, using 1.0.2
version of kotlinc
compiler on mac.
This is a known limitation in the Kotlin REPL. Destructuring declarations work fine in the source code (.kt files).
Here's the issue in the bug tracker: https://youtrack.jetbrains.com/issue/KT-5620
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With