3 ms·
Don't know Elixir. Understand a bit about pattern matching from dabbling in OCaml and F#. Not clear about this: >you have to basically mentally imagine what al
by vram22 6y ago
Don't know Elixir. Understand a bit about pattern matching from dabbling in OCaml and F#. Not clear about this:
>you have to basically mentally imagine what all cases are covered and what they mean
Why? Isn't the logic clearly specified in some way by the multiple dispatch/multi-methods? Because if not, how does the program work? So shouldn't a user be able to read the multi* code, and understand it, just like they can with if/else statements?
- dnautics 6y agoone difference is that you can really afford to be lazy with elixir. If your pattern match fails, one option is to let it throw a MatchError. Especially if the failure is rare, you just let the process die and your supervisors will restart the process into a sane state, and hopefully the next time you hit the code path it will be ok (for example: you are calling out to a 3rd party web service and they have a brief service outage, or some backhoe went over a network link and killed your packets).