TUPLES are ordered groupings of elements that can contain different types of variables. TUPLES are useful when you need to group heterogeneous data temporarily.
That is, basically a TUPLE is like a mail package left at your door, where they have taken other packages and wrapped them with duct tape to make a single package.

Unlike collections, TUPLES allow containing elements of different types (in fact, that’s their main purpose).
On the other hand, unlike OBJECTS and STRUCTS, TUPLES do not have a defined structure. They are often used to group elements temporarily or to return multiple values from a function.
Another very important characteristic is that tuples are immutable. This means that once created, they cannot be modified (this prevents accidental or unwanted modifications).
Finally, in general TUPLES are more efficient in terms of memory and performance compared to mutable data structures.
Examples of tuples in different languages
The syntax for declaring a TUPLE varies depending on the programming language being used. Let’s see examples in some popular languages:
// Tuple declaration
var persona = (nombre: "Luis", edad: 25, altura: 1.75);
// Accessing elements of a tuple
var nombre = persona.nombre; // Accesses the person's name
var edad = persona.edad; // Accesses the person's age
// Tuple declaration
#include <tuple>
std::tuple<std::string, int, double> persona("Luis", 25, 1.75);
// Accessing elements of a tuple
std::string nombre = std::get<0>(persona); // Accesses the person's name
int edad = std::get<1>(persona); // Accesses the person's age
In JavaScript, there is no specific data type called “tuple”, but you can achieve something similar using arrays. For example:
Although an array in JavaScript is mutable (can change), we can lock it with Object.freeze()
// Tuple declaration
const persona = Object.freeze(["Luis", 25, 1.75]);
// Accessing elements of a tuple
let nombre = persona[0]; // Accesses the person's name
let edad = persona[1]; // Accesses the person's age
# Tuple declaration
persona = ("Luis", 25, 1.75)
# Accessing elements of a tuple
nombre = persona[0] # Accesses the person's name
edad = persona[1] # Accesses the person's age
In the previous examples, we created TUPLES containing related information about a person, such as name, age, and height.
Internal Operation Advanced
A TUPLE is simply a data structure that contains a fixed number of elements, where each element can have a different data type. We don’t impose any further limitations.
So, internally, some languages represent it contiguously in memory. Others, as a memory area with references to other objects. Each will use its own system, it doesn’t really matter to us.
When accessing an element of a TUPLE, the programming language may use a system of indices or labels (as in the case of Python or C#) to find the location in memory of the desired element.
In other cases, such as in C++, a template system can be used to define TUPLES of different types and access elements via indices.
On the other hand, the immutability of the TUPLE is nothing “magical”. The programming language simply prevents its elements from being modified, just as it does with constants, for example. This ensures that the data remains constant and predictable throughout the tuple’s lifetime.
