0PricingLogin
Zig Academy · Lesson

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

  1. Declaring Structs and Fields
  2. Methods and the self Parameter
  3. Default Field Values
  4. Anonymous Structs and Tuples
← Back to Zig Academy