#Hi guys, I don't understand what this "sentinels in arrays" thing is. Could you explain it better?

1 messages · Page 1 of 1 (latest)

worthy root
#

I'm learning about arrays, but I was advised to understand sentinels before moving on to strings, which in Zig are chunks of 8-bit unsigned integers. However, I'm having trouble understanding how they work.

modern trench
#

It's just that the array is followed by an additional element (beyond the length) – the sentinel. Usually (especially in strings), the sentinel is a 0.

worthy root
modern trench
#

Yes, that's especially made for compatibility with C strings, while preserving Zig's known length approach.