-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Zig
By :
It’s time to jump into arrays, the simplest of data structures. Just a good old-fashioned, fixed-size collection of items, neatly packed together like so many cats crammed into a duffel bag. The analogy may seem uncomfortable, but trust me, once you understand arrays in Zig, you’ll be purring with delight (or hissing with envy, depending on your personality).

Figure 8.1 – No room to grow: fixed-size collections like cats in a bag
In Zig, arrays are plain and predictable: they have a fixed size known at compile time, and you can’t just go around resizing them mid-flight because you feel like it. If that’s too limiting for you, well, maybe arrays aren’t your cup of tea. But hey, some of us appreciate the simplicity. Arrays store a sequence of elements of the same type, arranged in a contiguous block of memory. Nothing fancy—just a disciplined row of data soldiers, ready for duty.
...