Velo by Example: Tuples

Tuples hold a fixed number of values of different types. Elements are accessed by position (1-based).

Create tuples with new tuple(...). The type specifies the element types.

tuple[int, str] pair = new tuple(1, "second");
tuple[int, str, float] triple = new tuple(42, "text", 3.14);

Access elements using .1, .2, etc. Note: indexing is 1-based.

tuple[int, str] p = new tuple(1, "second");
int first = p.1;      # 1
str second = p.2;     # "second"

Tuples are mutable — you can reassign individual elements.

tuple[int, str] p = new tuple(1, "hello");
p.1 = 42;
p.2 = "world";