SplitScript reference / Language / struct

struct

declaration

struct Name { field: Type }

Declares an immutable nominal structure.

Structs provide named fields, structural equality when their fields support it, and fixed process-memory layouts when every field is readable. In a literal, Name { field } is shorthand for Name { field: field }; an explicit repeated initializer receives a safe shorthand fix, and renaming either identity expands the shorthand when needed. In match and binding pattern positions, Name { field, other: pattern } binds field, recursively tests other, and ignores omitted fields without requiring a .. marker. The name may be omitted as { field, other: pattern } when the surrounding value already has one concrete struct type; this remains nominal matching rather than structural inference.

Examples

Group related values

struct Position {
    x: f32,
    y: f32,
}