|
|
|
|
|
by ufo
1992 days ago
|
|
I think I might disagree with #3. I find that having arr[-1] point towards the last element of the array can hide accidental off-by-one errors. It's also a bit weird how the arrays are zero-based if you access them normaly but one-based if you access them backwards. IMO it's more consistent to make the negative indexes behave the same way as an out of bounds access like arr[arr.length + 1] |
|
I’m still in agreement that negative indices make it more confusing than just calculating based off the length, but I get why they exist.