Structs and Records
Structs
Section titled “Structs”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 };Records
Section titled “Records”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}Accessing fields
Section titled “Accessing fields”fun lengthSquared(v: Vec2) Int { return v.x * v.x + v.y * v.y;}Example
Section titled “Example”struct Door { label: String, open: Bool,}