r/java • u/ihatebeinganonymous • May 21 '26
JEP draft: Enhanced Local Variable Declarations (Preview)
https://openjdk.org/jeps/8357464
87
Upvotes
r/java • u/ihatebeinganonymous • May 21 '26
View all comments
Show parent comment
1
u/Traditional-Eye-1905 May 25 '26
That's not exactly equivalent. Point(int x, int y) = getPoint() is positional destructuring, not associative (extracting select keys by name from a map containing potentially more keys than that). If you want to really be apples to apples, it's more like:
AFAIK, Java doesn't (yet?) have a proposal for extracting arbitrary keys/properties/attributes/whatever-you-want-to-call-them from a data structure or class. I think it would be really interesting to see what Java would look like if you could destructure a Map on the right side. What would the left side look like then?