Skip to content

Structs and Records

Structs are useful for value data:

struct Vec2 {
x: Int,
y: Int,
}

Create a struct with a literal:

var point: Vec2 = Vec2{ x: 3, y: 4 };

record syntax exists in language examples and docs history, but it is not implemented yet. Use struct for this kind of data shape today.

record Person {
name: String,
age: Int,
email: String
}
fun lengthSquared(v: Vec2) Int {
return v.x * v.x + v.y * v.y;
}
struct Door {
label: String,
open: Bool,
}