Structs
Spice offers support for C-like structs to aggregate variables in groups.
Usage¶
To declare a struct
, list all field types with names like this:
Structs can only be declared in the global scope, like functions and procedures.
For creating an instance of the declared struct, you can pass values for either all or none of the fields in curly braces. To access a field of the instance, you can address the field by its name: