Tuples
A tuple is an ordered grouping of values. Tuples are useful for returning or destructuring multiple values without defining a struct.
Tuple Literal
Tuples are written using parentheses:
var t = (10, 20);
You can access tuple members using numeric indices:
printf("%d\n", t.0); // 10
printf("%d\n", t.1); // 20
Returning Tuples from Functions
Functions can return multiple values by specifying a tuple type in the return position:
fn pair(x: int, y: int) (int, int) {
return (x, y);
}
Tuple Destructuring
Tuples can be destructured into variables directly:
fn main() {
var (x, y) = pair(10, 20);
printf("(%d, %d)\n", x, y);
}
Const Tuple Destructuring
Using var makes all destructured elements mutable.
Using const makes all of them immutable.
fn main() {
const (x, y) = (5, 6); // both x and y are immutable
}
Mixing Declaration Forms
Tuple destructuring respects normal variable declaration rules. Global destructuring is not allowed — tuples can only be destructured inside functions or local scopes.
Nested Tuples
Tuples can be nested:
fn main() {
var (x, (y, z)) = (1, (2, 3));
printf("%d %d %d\n", x, y, z); // 1 2 3
}

