According to the Kotlin docs on destructuring declarations, the declared components should match the number of components on the right side:
Anything can be on the right-hand side of a destructuring declaration, as long as the required number of component functions can be called on it.
However, I discovered that this works even if the left hand side doesn't have the same number of components as on the right side of the assignment statement.
fun main() {
val (firstOnly) = Pair("key", "value")
println("firstOnly=${firstOnly}")
}
Is this legal Kotlin or is this is a bug? If it's legal, is there a reference?
Pairhascomponent1(), so no problems here.