Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Offset-based lets you refer to an abstract location that is after the last element without resorting to n + 1.

  [ ] [ ] [ ] ...    [ ]
 0   1   2   3   n-1     n

We can regard this n as a "virtual zero", and then make it possible to index the n - 1 element also indexable as just -1. The index -n then aliases to 0.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: