October 2014
Intermediate to advanced
280 pages
7h 20m
English
if and unless
cond (a multiway if)
case (a pattern-matching switch)
Exceptions
We’re quite a long way into our exploration of Elixir. But so far we haven’t seen many if statements, or anything else that looks like a conventional control-flow statement.
There’s a good reason for that. In Elixir we write lots of small functions, and a combination of guard clauses and pattern matching of parameters replaces most of the control flow seen in other languages.
Elixir code tries to be declarative, not imperative.
Elixir does have a small set of control-flow constructs. The reason I’ve waited so long to introduce them is that I want you to try not to use them much. You definitely will, and should, drop the occasional if or ...
Read now
Unlock full access