Re:Anti-if: The Missing Patterns
by chriswarbo on Friday June 10, 2016 @06:10AM
(#11875351)
Unfortunately, pattern matching isn't available in many languages (or at least, including a new dependency for the sake of removing `if`s may not be worth it).
On the other hand, the article recommends using sub-type polymorphism, which is also unavailable in many languages.
IMHO These are by far the two most important ways to get rid of complex code embedded with ifs.
One very good example of this is erlangs factorial method.
There are many other nice examples at the erlang documentation:https://www.erlang.org/course/sequential-programming#funcsyn...