Comment by vips7L
4 months ago
What language are you using that doesn’t have match? Even Java has the equivalent. The only ones I can think of that don’t are the scripting languages.. Python and JS.
4 months ago
What language are you using that doesn’t have match? Even Java has the equivalent. The only ones I can think of that don’t are the scripting languages.. Python and JS.
Does Java have sum types now?
Yes via sealed classes. It also has pattern matching.
So they are there, but ugly to define:
In Kotlin it's a bit better, but nothing beats the ML-like langs (and Rust/ReScript/etc):
4 replies →
I think Java 21 does. Scala and Kotlin do as well.
Python has it as well.
Ah my mistake. It’s been at least 5 years since I’ve written it. I’m honestly surprised that JS has moved no where on it considering all of the fancy things they’ve been adding.
It has been proposed, but since there is all the process on how features get added into the standard, someone needs to champion it, and then there is the "at least two implementations" factor.
https://github.com/tc39/proposal-pattern-matching
[dead]