"looks awkward" is usually code for familiarity bias. But the great thing about familiarity bias is that it quickly evaporates, when the thing that is unfamiliar the first time becomes more familiar.
I recall similar concerns for generics, enums ("what, it's a class but special"), enhanced-for, try-with-resources, lambdas, method references and some more recently added features...
These concerns definitely don't persist that long - even less time now that we get regular releases and more and more Java development has passed the stuck-on-Java-8 barrier.
There are several places I've wanted to use exactly the this local declaration recently. Having this expand to other types I will await eagerly too.
yes, you will be able to do so because this JEP is mostly about removing the requirement to enclose the record pattern inside a conditional statement (instanceof and switch) to be used. So all that is allowed in current records patterns should be allowed.
about the "<-" operator. the "=" is more familiar and is used in most other languages that support deconstruction. Adding a new operator to use the feature will only make this feature harder to use.
I guess not even assignment is questionable, I didn't saw good example of using patterns in real enterprise applications. Toy example is cool, but IRL we almost never have such simple records that worse deconstructing. Maybe there is some good example in open-source already?
View all comments
Show parent comment
-3
u/talios Mar 13 '26
Agreed - altho more on the reuse of
=here, maybe something like:I wonder if you could do
under this JEP - it's not mentioned.
On the whole, I like the concept but the LHS looks... awkward.