Four Ways To Do Control Flow In Elixir Language — Tentamen Software Testing Blog


In the previous post, we explain three ways how to run the Elixir script. Today we present four ways how to do control flow in Elixir. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.

Pattern Matching

Pattern matching is a new way of solving problems in functional languages. I first met with pattern matching in Elixir. You probably met with regular expression matching, where the pattern is a String. In Elixir, a pattern is not only a String.

Multiclause Functions

In Java, you can overload a function with the same name and different input parameters. This is similar in Elixir, but with the addition of pattern matching, that gives you much more flexibility.

Conditional Expressions

Here we have traditional if then else. But Elixir also has with, case and cond statements. More flexibility for programmers.


There is no traditional While, For, and Loop statement. But using functional recursion, you can solve all looping problems, with no more than OO complexity.

We will first start with pattern matching in the following blog post.

Originally published at on November 26, 2020.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Karlo Smid

Karlo Smid

Founder of Tentamen, software testing agency.