Pattern matching with `Kernel.match`
Pattern matching is powerful, but when iterating over a list with an Enum function you must allow all variants of the list to be processed. So this fails:
Instead of using pattern matching here we can just use an anonymous function that takes all args and makes a comparison.
But the cool way to do it is with Kernel.match?
. Which according to the docs is:
A convenience macro that checks if the right side (an expression) matches the left side (a pattern).
What that looks like:
H/T Taylor Mock
Tweet