News for hackers. Stuff that matters.
Re:Why numbering should start at zero (1982) by zepolen on Thursday December 15, 2016 @04:28PM (#13188584)
I like to think of it like this:

For 0 based indexing the punctuation is the indexes/offsets:

  [    a    ,    b     ,    c    ]
  0         1          2         3
for 1 based indexing consider the actual elements are the indexes/positions:

  [    a    ,    b     ,    c    ]
       1         2          3
In the first case it is non inclusive, ie.

  elements[0:3] - all items between offset 0 and 3
The second case is inclusive, ie.

  elements[1:3] - all items including 1 and 3

Personally I don't have an issue with either, they both 'make sense'

Where they stop making sense is when you'd mix up the inclusivity ie (for the second case).

  elements[1:4] - including item 1 not including 4

There are no comments on this comment yet.