Class reference

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 Struct()

Constructs an empty Struct with no schema (a null struct).

Struct Struct(Struct from)

Constructs a Struct as a copy of from, duplicating its schema reference and field values.

Operators

bool operator !=(Struct right)

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 ==(Struct right)

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 [](Variant key)

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.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.