Hacker News new | ask | show | jobs
by KnobbleMcKnees 1061 days 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.
1 comments

As 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].