News for hackers. Stuff that matters.
Re:Java 21: What’s New? by the-smug-one on Wednesday August 09, 2023 @06:16PM (#37069151)
You'd do if (getPoint() instanceof ...) if you know it's a Point. But then, you probably don't need to deconstruct it anyway. You can just do p.x+p.y.

This type of pattern matching is mostly useful when you have some T and a few cases, there is also a switch/case equivalent for when you've got a lot of them.

Maybe we'll see some syntax for deconstructing values directly into variables, a la Python in the future.

There are no comments on this comment yet.