Tuples

Let’s learn about the uses of tuples in Elixir, along with some tuple traps.

We'll cover the following

Tuples are fixed-length data structures. Like all Elixir data structures, they are immutable. We can access or pattern match against any element of the tuple efficiently. This lesson will show you the types of problems we can generally solve with tuples. Let’s take a look at them.

Good tuples

Generally, think of tuples as structures where the position within the tuple means something. Coordinates, {key, value} pairs from maps, and {city, state} pairs are all excellent examples of what we’ll see in tuples.

Executable

Get hands-on with 1200+ tech skills courses.