This is a great example of ruby’s malleability. As an added bonus, you can use the same technique to add support for elixir-esque argument pattern matching as shown in this gem: https://github.com/vizvamitra/patme (of course, it makes the code even slower, but it’s still fun!)
This is a great example of ruby’s malleability. As an added bonus, you can use the same technique to add support for elixir-esque argument pattern matching as shown in this gem: https://github.com/vizvamitra/patme (of course, it makes the code even slower, but it’s still fun!)
Wow, that’s cool. I thought I had seen every Ruby trick! But 14x slower means this should be used rarely.
Isn’t that Ruby’s equivalent to Elixir’s pattern matching?