Making Two Things Match
Learn about Elixir's pattern matching.
We'll cover the following...
Introduction to pattern matching
Controlling the program flow means controlling which functions and expressions will be executed. Imperative languages rely mainly on conditional constructors like if
, but here in the functional world, pattern matching plays the central role. However, pattern matching is often misunderstood and challenging for beginners to comprehend, which is why half of this chapter is dedicated to understanding it.
We’ll then use pattern matching to decide which function to dispatch to have a ...