3 ms·
I see what you did there. And Swift, the very language the author is comparing to, has this functionality.
by happytoexplain 5y ago
I see what you did there. And Swift, the very language the author is comparing to, has this functionality.
- deltaonefour 5y agoSo does Haskell and Rust. It's called exhaustive pattern matching on sum types with the Maybe monad (or Optional). I believe Haskell popularized this syntax and Rust and Swift borrowed it from Haskell. Strictly speaking though, haskell pattern matching isn't exhaustive but the compiler will give you a warning if your code doesn't handle every case. Elm is another language that exploits this feature to a scale where unless you use the FFI, elm programs cannot logically ever crash.