(no title)
lifewallet_dev | 2 years ago
type when expression -> block
if expression -> block
For parsing works better, for programmers is better since they don't confuse both concepts, and in general pattern matching isn't the same as a if condition or a switch.https://stackoverflow.com/questions/199918/explaining-patter...
I think the difference is when you start pattern matching on tuples and other types that you cannot do a simple `if ident.isinstanceof(type) ->`.
For example in Elixir you can do:
def ident(param = {:key => true}):
This will only match when the param type is not only `map`, but also contains a key named `:key` and its value is `true`.In the end though, it's syntax sugar (but everything is if you put it that way classes are syntax sugar).
No comments yet.