4 ms·
Oooh that's a good idea. Does that already exist in other languages? I've not seen it before.
by sleavey 7y ago
Oooh that's a good idea. Does that already exist in other languages? I've not seen it before.
- nestorD 7y agoOcaml, F#, Rust, Kotlin (I believe), Haskell, etc It is a common feature in languages derives from the ML family[0]. [0]: https://en.wikipedia.org/wiki/ML_(programming_language) https://en.wikipedia.org/wiki/ML_(programming_language)
- kod 7y agoKotlin doesn't have real pattern matching.
- lllr_finger 7y agoIt doesn't, but at least 'when' statements will be exhaustive when working with sealed classes - which is a breath of fresh air if you enjoy working with sum types and pattern matching.
- kod 7y agowhen expressions will be exhaustive, when statements will not. Needless distinctions like that make the fresh air a little less fresh...
- walkingolof 7y agoScala has had this for a long long time: https://docs.scala-lang.org/tour/pattern-matching.html https://docs.scala-lang.org/tour/pattern-matching.html
- deleted 7y ago[deleted]
- johnlinvc 7y agoSwift also have them.