Java sealed classes and exhaustive pattern matching
24 points by hnisjafx40 2 hours ago | 5 comments
timshel2 2 minutes ago
Scala punching the air rn
replyarmchairhacker 57 minutes ago
Java also has recursive patterns and (maybe still in preview) literal patterns: `switch (x) { case A(B(true, var c)) -> f(c); }`
replyLarrikin 56 minutes ago
Java continues to try and catch up to Kotlin
https://kotlinlang.org/docs/sealed-classes.html
replyI didn't mind Java when the comparisons were to C++, Ruby, and Python. I can not find a reason to go back after Scala (which seemed to fail due to being indiscriminate) and especially Kotlin
sideeffffect 28 minutes ago
> Java continues to try and catch up to Kotlin
replyDoes it, really? Java has had pattern matching since 21 (2023). Kotlin still, to this day, the year of our Lord 2026, doesn't...