Kotlin 解构变量不适用于 Pair、Triple 或数据 class

Kotlin destructuring variables is not working with Pair, Triple or data class

我最近在 kotlinc 命令行环境中尝试了以下代码。

var greet = Pair("Hello", "World")
val (word1, word2) = greet

在控制台中输出 word1word2 输出以下消息

>>> word1
error: unresolved reference: word1
word1
^

我不确定是否从最新版本的 kotlin 中删除了解构。目前,在 mac.

上使用 1.0.2 版本的 kotlinc 编译器

这是 Kotlin REPL 中的已知限制。解构声明在源代码(.kt 文件)中工作正常。

错误跟踪器中的问题如下:https://youtrack.jetbrains.com/issue/KT-5620