-
Notifications
You must be signed in to change notification settings - Fork 0
Structs
Julius Paffrath edited this page Jun 28, 2026
·
4 revisions
A struct is a data type gathering around other variables, called fields:
struct Car
set name to ""
set hp to 0
endstruct
set bmw to Car(name = "BMW", hp = 120)
print("I am driving a " + bmw->name + " with " + bmw->hp + " HP!")
The set-statements for defining the fields will get evaluated every time a new struct is initialized. One has to bear this in mind if fields are evaluating to dynamic values.
Structs are, like lists, immutable. In order to update a field, the struct has to be copied:
set bmw to bmw update name = "Mercedes" update hp = 218