Struct
A map with known, named fields, the type behind every record-like value from an address to a signed Change.

· Core Type

A struct is the kind for named fields. properties fixes each field. The struct is closed, so unlisted keys are rejected, unless it adds a values tail. A map has no named fields: every value matches one values schema.

A struct is a map whose keys are known in advance. Its struct schema lists them under properties, one property per field: the field's value schema, whether it is required, and a description. It is closed unless it also gives values, the schema every extra key must satisfy. In the data model a struct is still a map. The difference lives in the schema: a form knows which fields to show, a validator knows which keys are stray, and a generated type gets named members.

Use a struct when the fields have names and meanings of their own: a person has a name and an age, and a Change has a genesis and deps. Use a map when the keys are data, such as word to count or key to value. The reference examples are Example: Person for a struct and Example: Counts for a map.

See also

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Connections0

Connections show where other documents or comments link to this document.

Related documents

Loading connections…