April 2026
Intermediate
683 pages
25h 29m
English
In a nutshell, a tuple is a group of values combined together. It’s that simple! Instead of having dozens of scattered variables all over the place, tuples let us group related variables together, keeping things tidy and improving code readability—to say the least. Tuples also have other uses, which you’ll see in upcoming chapters. In this section, we’ll focus on how they work.
In the most basic sense, a tuple is a set of variables placed inside two parentheses—nothing more! Check the code in Listing 2.92 to see how easy it is to build a tuple and access the variables within.
// Tuple with single typelet cars = ("Mercedes", "Ford", "Volvo")cars.0cars.1cars.2// Tuple with multiple typeslet person = ("John" ...
Read now
Unlock full access