How To Pattern Match Lists In Elixir — Tentamen Software Testing Blog

Karlo Smid
Jan 8, 2021

--

Elixir List Pattern Matching

TL;DR

In the previous post, we presented Variables In Elixir Pattern Matching. Today we explain how to make pattern matching on Elixir lists. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.

We pattern match Elixir list similar as Elixir tuples. We can use variables, pin operator, and anonymous variables.

As Elixir lists have one special operator, | for extracting list head and tail, we can also use this operator in List pattern matching.

Originally published at https://blog.tentamen.eu on January 8, 2021.

--

--

Karlo Smid
Karlo Smid

Written by Karlo Smid

Founder of Tentamen, software testing agency.

No responses yet