Re:Java record pattern matching in JDK 19
by peterkelly on Saturday May 14, 2022 @08:05PM
(#31383956)
The downside to that is if you want to write a new function that deals different subclasses, you can't keep all the logic in one place; you have to spray its implementation across all the different types it has to handle. This is the #1 reason I prefer languages with sum types and pattern matching (or the ability to emulate it via unions and instanceof checks, e.g. TypeScript or Python + mypy).
[ Parent
| on HN ]