Composite Type Field Getters and Setters
🚧 Status: Field getters and setters are not implemented yet.
Fields may have an optional getter and an optional setter. Getters are functions that are called when a field is read, and setters are functions that are called when a field is written. Only certain assignments are allowed in getters and setters.
Getters and setters are enclosed in opening and closing braces, after the field's type.
Getters are declared using the get
keyword. Getters have no parameters and their return type is implicitly the type of the field.
Setters are declared using the set
keyword, followed by the name for the new value enclosed in parentheses. The parameter has implicitly the type of the field. Another type cannot be specified. Setters have no return type.
The types of values assigned to setters must always match the field's type.
Last updated