2 ms·
It's a fairly common pattern. Essentially it's a slightly cleaner way of doing a multiway conditional rather than if and else. Ruby has it explicitly (case, wh
by neilwilson 7y ago
It's a fairly common pattern. Essentially it's a slightly cleaner way of doing a multiway conditional rather than if and else.
Ruby has it explicitly (case, when, else), and of course functional languages with pattern matching operate like this as a matter of course. A Boolean guard followed by the code to run if the guard is matched.