forked from fox-archives/volant
-
Notifications
You must be signed in to change notification settings - Fork 4
Tuples
Apoorv Singal edited this page Aug 30, 2020
·
1 revision
A tuple is a user-defined data type that stores a group of values of different types.
Tuple types are defined using the tuple
keyword.
tuple Name {type1, type2, type3};
tuple Tuple{u8, u32};
var: Tuple; // declares var of type Tuple
var := (Tuple){0, 1}; // initializes var with values 0 and 1
Elements of a tuple are accessed just like arrays with the syntax of tupl[index]
. There is only one restriction, index
must be an integer literal.
Tuples are allocated on stack by default. See heap for details on how to allocate tuples on the heap.