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

Elixir Does Not Have While Statement

TL;DR

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.

Loops

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 https://blog.tentamen.eu on November 26, 2020.

Founder of Tentamen, software testing agency.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Setup Ruby On Rails on Ubuntu 16.04 Xenial Xerus

Stored Procedure vs View

difference between view and stored procedure

Precious stones on GitHub

How should CSS being setup (Part 2)

Git — Commands that saves the world

Why your Lambda functions may be doomed to fail?

Azure Kubernetes Service (AKS) with Different Monitoring Solutions

Summary of what I learned in Design Pattern: State

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.

More from Medium

My Elixir port of Hugging Face Hub APIs

An opinionated Elixir Style Guide #2

Goodbye Elixir (for now)

Implement Sigil in Elixir