Attention: Here be dragons (unstable version)
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Redot.
Checking the stable version of the documentation...
Struct
A schema-backed container of named, typed fields with value semantics.
Description
Struct is a fixed-layout container whose fields are described by a shared schema (name, type, and optional default per field). Unlike Dictionary, a struct has value semantics: copying a struct copies its field values, and two structs compare equal when they share the same field layout and all field values are equal.
Fields are accessed by name (a StringName or String) or by integer index through the [] operator. Values assigned to a field are validated against the schema and coerced to the field's declared type; incompatible values are rejected.
Note: The schema itself is created and managed internally; structs are typically obtained from typed APIs or from GDScript struct declarations rather than constructed field-by-field from script.
Constructors
Struct() |
|
Operators
operator !=(right: Struct) |
|
operator ==(right: Struct) |
|
operator [](key: Variant) |
Constructor Descriptions
Constructs an empty Struct with no schema (a null struct).
Constructs a Struct as a copy of from, duplicating its schema reference and field values.
Operator Descriptions
bool operator !=(right: Struct) 🔗
Returns true if the two structs are not equal, that is, if they have a different field layout or any field value differs.
bool operator ==(right: Struct) 🔗
Returns true if the two structs are equal. Structs are equal when they share the same field layout and all corresponding field values compare equal; structs with different layouts are never equal.
Variant operator [](key: Variant) 🔗
Accesses a struct field. The key may be the field name (a StringName or String) or the integer field index. Assignment is validated against the struct's schema: incompatible values are rejected, and accepted values are coerced to the field's declared type.