Now that you’re familiar with Elixir’s basic building blocks, it’s time to look at some typical low-level idioms of the language. In this chapter, we’ll deal with conditionals and loops. As you’ll see, these work differently than in many imperative languages.
Classical conditional constructs, such as if and case, are often replaced with multiclause functions, and there are no loop statements, such as while. However, you can still solve problems of arbitrary complexity in Elixir, and the resulting code is no more complicated than a typical object-oriented solution.
All this may sound a bit radical, which is why conditionals and loops receive detailed treatment in this chapter. But before we start discussing branching and looping, you need to learn about the important underlying mechanism: pattern matching.