Pattern matching is such a powerful feature. I wish more languages (like python) would realize it’s value and add it.
Pattern matching is such a powerful feature. I wish more languages (like python) would realize it’s value and add it.
https://cr.openjdk.java.net/~briangoetz/amber/pattern-match....
I've used Scala before.
There are some cases, like compilers where I could see matching and extracting complex and nested patterns to be useful.
But in most cases monadic operations/functors plus if/else seems pretty much as good.
I probably use monadic operations (map, fold, etc) at least 5-10 times a day in my job (I’m a scala dev), and match expressions at least 3-5 times a day.
So pretty useful I’d say. Though then again I’m dealing with some pretty baroque case classes that contain dozens of values of financial information.
Scalaz and cats are perhaps the most common dependencies in the Scala ecosystem.