3 ms·
Basically this is Elixir's case, so a very narrow instance of what Elixir's pattern matching is. I'd love to see more pattern matching added to Ruby year after
by pmontra 7y ago
Basically this is Elixir's case, so a very narrow instance of what Elixir's pattern matching is. I'd love to see more pattern matching added to Ruby year after year. However adding everything Elixir has probably would require a total rework of the language. Example: multiple method definitions, one per pattern.
I wonder what's going to be the idiomatic way to handle a failed match. Elixir ends the process but there is likely a supervisor to restart it. In the case of Ruby the process ends and there is nothing to restart it. In the case of Rails I expect the web request to fail with a 500 and maybe the next one will get more luck.
- riffraff 7y agoThere seem to be plans to extend this to destructuring assignment/bind, that would be a ton more useful and interesting imo.