The KEEP for name-based and new positional-based d...
# language-proposals
a
The KEEP for name-based and new positional-based destructuring is now open for public review https://github.com/Kotlin/KEEP/discussions/438
K 5
K 6
💯 1
z
Seems good. I'm curious though why parenthesis instead of curly brackets? Wouldn't it be more appropriate for brackets since they're typically associated with objects? example
Copy code
{ val a, val b } = Pair(1, 2)
In my opinion it's more natural I think Another thing what if the `val`/`var` could be lifted out the destructuring block if theyre all the same? Correct me if I'm wrong but immutable fields would be more common when destructuring. So it would be simpler to write for example
Copy code
val { a, b } = Pair(0, 1)
a
Brackets are not possible because they're already used to delimit blocks and lambdas. When the parser sees
{ val x
, it cannot distinguish whether a new block is starting, or a destructuring is starting
about the second question, the KEEP defines a migration strategy to finally get to the usual
val (a, b)
syntax (or
val [a, b]
) we all know and love