Structs are user-defined data types with named fields.
Declare a struct by naming it followed by field names in {}:
Or on one line:
No types. dryLang is dynamically typed — fields accept any value.
Create an instance by providing the variable name, struct type, and field values:
Use dot notation:
Or bracket notation:
Structs are internally represented as maps. A struct instance is a map with field names as keys. This means all map functions work on struct instances:
| Feature | Struct | Map |
|---|---|---|
| Declaration | user { name age } | — |
| Creation | u user { name "Zaky" } | u {"name": "Zaky"} |
| Type identity | Yes (__struct__ meta) | No |
| Dot access | ✅ | ✅ |
| Bracket access | ✅ | ✅ |
| Dynamic keys | ❌ | ✅ |
Use structs when you want a named type with a fixed set of fields. Use maps when you need dynamic keys.