Tuples
This section describes how to use tuples to store multiple types in one variable.
Foundations
Section titled “Foundations”A tuple is an anonymous struct containing values of one or more different types.
Creating a tuple uses the signature: tuple<type, [type], [type…]> variable_name;
A tuple starts with all memory zero initialized and can be filled using an initializer list [ ] expression or by writing to number indexes corresponding to the types in the definition signature.
// make an empty tuple that can hold an i32, f32, and string tuple<i32,f32,string> t; println(t[0] as string + ", " + t[1] as string + ", " + t[2]); // 0, 0.000000,
// same thing, but fill with values tuple<i32,f32,string> t = [ 1, 2.5, "test" ]; println(t[0] as string + ", " + t[1] as string + ", " + t[2]); // 1, 2.500000, test
// assignment to index t[0] = 3; t[1] = 4.5; t[2] = "foo"; println(t[0] as string + ", " + t[1] as string + ", " + t[2]); // 3, 4.500000, foo