Skip to content

Structs

Julius Paffrath edited this page Jul 11, 2026 · 4 revisions

Introduction

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 to "Mercedes" update hp to 218

To distinguish structs cleanly from functions, structs start with a capital letter.

Clone this wiki locally