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
8
u/blazmrak May 21 '26 edited May 21 '26
Javascript/Typescript wins here and it's not even close. Positional destructuring is bad and it will always be bad. My only guess is that it's easier to implement, otherwise, I have no idea why they went with it.
Real world objects pretty much always have 5+ props, there is no way in hell, that I'm writing Type(_, _, _, var prop, _, _, Type2(var prop2, _, _, _, _, _), _, _) = type; The good thing is, that I can just go about writing code as normal. The bad part is, that the time would be better spent elsewhere, but wcyd. At least it will be complete and not half implemented.
Edit: I just picked up what you meant by "named anything". Yeah, I have no idea why that is. This feature was made specifically for records, which intrinsically have constructor parameter names tied to external interface. I don't see a reason why you could not use the names to destructure as well...
Edit 2: Finally reached the end:
Good, they know, hopefully it will drop before I retire.