Tuples

A tuple type is written as (t, u) (or (t, u, v), etc.)
The functions a, b, c, etc., access elements of the tuple.
A tuple is created by calling new. See "new" functions for info about its syntax.

main void() tuple (nat, string) = 1, "foo" log tuple.a log tuple.b

You can destructure a tuple by writing multiple local names separated by commas.

main void() tuple (nat, string) = 1, "foo" n, s = tuple log n, s

All features of locals work inside destructuring, such as type annotations, mut, or _.

main void() n nat, s mut string, _ bool = 1, "foo", true s := "bar" log n, s

Even destructuring works inside destructuring.

main void() tuple (nat, (string, string)) = 1, ("foo", "bar") a, (b, c) = tuple log a, b, c

Parameters can destructure tuples too. Since parameter types are required, each part of the destructure needs a type.

main void() tuple (nat, string) = 1, "foo" foo tuple # The parameter type is (nat, string) foo void((n nat, s string)) log n, s