Declaring Structs and Fields
Group related data into a type.
Group Related Data
Loose variables get messy fast. A struct lets you bundle related values into one named type you can pass around together.
struct Is an Expression
In Zig a struct is created with the struct keyword and a body. You usually bind it to a const to give the type a name.
const Point = struct {};All lessons in this course
- Declaring Structs and Fields
- Methods and the self Parameter
- Default Field Values
- Anonymous Structs and Tuples