Anonymous Structs and Tuples
Create ad-hoc grouped values.
Sometimes You Need It Once
Not every grouping deserves a named type. Zig lets you write an anonymous struct inline, right where you use it.
Just Drop the Name
An anonymous struct literal starts with .{ and lists fields by name, with no type written before it.
const p = .{ .x = 1, .y = 2 };All lessons in this course
- Declaring Structs and Fields
- Methods and the self Parameter
- Default Field Values
- Anonymous Structs and Tuples