Tuples
Tuples group a fixed number of values together in order.
They are useful when a function should return several values at once, or when a small group of values belongs together without needing a full struct type.
let pair := 10, 20;let coords : <int, int, int> = (3, 7, 9);You will also see tuple values written with the tuple(...) helper.
let point := tuple(5, 6);Tuples can be destructured directly.
let mut first, mut second := tuple(1, 2);print(first + second);You can also destructure only part of a larger tuple with ...
let values := 10, 20, 30, 40;let start, .., end := values;
print(start + end);Tuple destructuring works in assignments too.
let mut x := 0;let mut y := 0;
x, y := tuple(5, 6);print(x + y);Functions can destructure tuple parameters directly.
const sum_pair := fn ((a, b)) => a + b;print(sum_pair((7, 8)));Tuples also work naturally in pattern matching.
match 10, 90, 20 { 10, mut value, 20 => print(value), 10, .., 20 => print("matched"), _ => {}};Use tuples when order matters and the values are best understood by position rather than by field name or when each member needs their own type;