Struct - Structure
The struct or structure statments (both are synonyms in FISH) are used to define or create structure types.
If used at the start of a line of input, then the struct statement defines a new structure:
struct fred(mem1,mem2,mem3)
The name following struct is the name of the new structure. The arguments following are the names of the structure members. Both structure names and member names must follow the rules for names, however structure names and member names can be the same as global symbols.
Note that this structure definition happens when the FISH function is parsed, and not when it is executed.
If a structure of that name already exists and does not exactly match the previous definition, an error will be thrown.
An alternative method of defining structures is to use the fish structure
command.
Structure definitions are part of the model state.
This means the are saved and restored with the model, and are removed with a model new
.
If used in an expression, the struct keyword is used to create a structure type. In this case the arguments following are optional, and are used to initialize the structure members in the order declared in the structure definition.
The following is an example of using the struct keyword:
local a = struct fred(1,'a',list.range(1,10))
my_function_call(struct fred(5,7.8,'monkey'))
Was this helpful? ... | Itasca Software © 2024, Itasca | Updated: Dec 14, 2024 |