Chapter summary
Arrays are contiguous sequences of data of the same type and fixed length. We declare them with an explicit size or let Zig infer it.
- To access elements in an array, we use indexes. Those indices start at 0.
- .len is the property that tells us the length of an array.
- Mutable arrays let us modify the values stored at the indexes, but they don't allow us to change their length. An array always has a fixed length.
- A slice is a view over an array. It doesn't own the data; it just points to a part of the underlying array. Slices are often used to handle parts of arrays and pass them to functions without copying them in memory.
- We can repeat arrays or slices using ** and concatenate them with ++, as long as the data is known at compile time. The typical example of such a structure is a string literal.