A tuple expression constructs tuple values.
The syntax for tuple expressions is a parenthesized, comma separated list of expressions, called the tuple initializer operands. The number of tuple initializer operands is the arity of the constructed tuple.
1-ary tuple expressions require a comma after their tuple initializer operand to be disambiguated with a parenthetical expression.
Tuple expressions without any tuple initializer operands produce the unit tuple.
For other tuple expressions, the first written tuple initializer operand initializes the field
item0 and subsequent operands initializes the next highest field.
For example, in the tuple expression
(true, false, 1),
true initializes the value of the field
Examples of tuple expressions and their types:
A tuple field can be accessed via an attribute expression.
contract Foo: pub fn bar(): # Creating a tuple via a tuple expression let some_tuple: (u256, bool) = (1, false) # Accessing the first tuple field via the `item0` field baz(some_tuple.item0) pub fn baz(input: u256): pass