Struct

Structs group multiple values together.

Definition

Structs are defined with the struct keyword. After the keyword you have to specify the name of the struct. The fields are defined in a block after the name of the struct.
The fields are defined like variables, but without the let keyword and seperated by a comma.

Example

struct Person { name: string, age: int }

Initialization

Structs are initialized with the new keyword. After the keyword you have to specify the name of the struct. In the block after that you have to specify the values for the fields.
The fields are just initialized with an equal sign and the value you want to assign to the field.

Example

let person = new Person { name = "John", age = 20 }

Accessing Fields

You can access the fields of a struct with the . operator. After the operator you have to specify the name of the field you want to access.

Example

printLine(person.name); // John

Methods

Struct can have, just like all other types, methods defined via extend.