What Are Elixir Tuples And When To Use Them — Tentamen Software Testing Blog


In the previous post, we discussed Elixir’s short circuit operators and how those could help you to write less code. Today we explain what Elixir Tuples are and when to use them. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.

Tuple Syntax

In the image above you can see how we defined test_case Tuple. Tuple can have more than two elements. You get Tuple values using Kernel.elem function, and update it using. Kernel.put_elemAs Elixir is immutable, test_case is not changed, but a new variable is created in memory.

When To Use Tuples

We use tuples when we need to return from function simple data type. For example, to indicate that function returned an error with an error message.


  • What is Tuple syntax

Originally published at https://blog.tentamen.eu on July 27, 2020.

Founder of Tentamen, software testing agency.

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