4 ms·
It doesn't matter how cool the slice notation is when people have trouble accessing single elements! 1 based is better for human counting and 0 is better for c
by evanmoran 13y ago
It doesn't matter how cool the slice notation is when people have trouble accessing single elements!
1 based is better for human counting and 0 is better for certain mathematical expressions, usually when thinking about offset from the start rather then list position.
Clearly it is a judgement call, but I personally think counting is more important for the same reason PI is wrong. We are confusing ourselves because easy things aren't intuitive.
Imagine you have:
var list = ['first','second', 'third']
`list[2]` should clearly be the second element (not third), just as PI / 2 should mean half a circle (not 1/4).
We wonder why there aren't as many computer science / math grads. Well in every intro class in the world people are getting confused by this.
- IanCal 13y agoDepends on how you read `list[2]` "Start at the beginning and move two elements along" works perfectly well.