Composite Type Declaration and Creation
Structures are declared using the struct
keyword and resources are declared using the resource
keyword. The keyword is followed by the name.
Structures and resources are types.
Structures are created (instantiated) by calling the type like a function.
The constructor function may require parameters if the initializer of the composite type requires them.
Composite types can only be declared within contracts and not locally in functions. They can also not be nested.
Resource must be created (instantiated) by using the create
keyword and calling the type like a function.
Resources can only be created in functions and types that are declared in the same contract in which the resource is declared.
Composite Data Initializer Overloading
🚧 Status: Initializer overloading is not implemented yet.
Initializers support overloading. This allows for example providing default values for certain parameters.
Last updated