4 ms·
> It's one of the few things the programming community has settled on - indexing starts at 0, as it is mathematically the most natural start. When you're in th
by sidpatil 6y ago
> It's one of the few things the programming community has settled on - indexing starts at 0, as it is mathematically the most natural start.
When you're in the supermarket and you're counting how many items are in your shopping cart, do you start from 0?
- Jtsummers 6y agoIt depends on what you think you're doing. If you are counting, 1-based makes a lot of sense. If you're indexing, they're equally valid approaches. However, if you're indexing then you should be able to use an arbitrary range and not be restricted to one or the other (with a mapping function from your actual range to the language's base).
- mcguire 6y agoYou start with an empty cart, right?
- dragonwriter 6y ago> When you're in the supermarket and you're counting how many items are in your shopping cart, do you start from 0 Yes, because the cart starts empty. But, more to the point, I don't call the thing I put into the cart that causes it not to be empty the zeroth item.