4 ms·
You're describing counting, not numbering. Like how an array with a count of 1 has one item that is numbered by it's index, 0.
by KnobbleMcKnees 3y ago
You're describing counting, not numbering. Like how an array with a count of 1 has one item that is numbered by it's index, 0.
- CharlieDigital 3y agoAs a counterpoint to that, wouldn't it be kinda nice if an array index equaled the array length and index 0 was equivalent to an empty array. Think of a basket of apples. If you take the zeroth apple (empty basket), you have no apples. If you take the first apple, you have 1 apple and now the basket is empty again (0). One also wouldn't have to do [length - 1] to access the last index; it would naturally be [length].