4 ms·
A helpful way to think about this, especially when working in languages that have an array slice syntax, is that arrays are like rulers for measurement. Like a
by nhaehnle 15y ago
A helpful way to think about this, especially when working in languages that have an array slice syntax, is that arrays are like rulers for measurement.
Like a ruler, the array has markers (ticks) going from 0 to N, and the array elements are stored between ticks. So the index numbers simply refer to points, while the array elements have a "one-dimensional" extent.
With that mental model, starting at 0 falls into place very naturally.