|
|
|
|
|
by zdragnar
1358 days ago
|
|
So, to use some pseudocode: var item = my_array[2] should be read as "assign to item the value in my_array in the position where you would place something new just before the third item" 1-indexing is, strictly speaking, a better design. The only real argument for it anymore in a higher level language is "it's what I'm used to", or alternatively, "0 already won the popularity contest" (which is actually not a terrible argument in context, though it is a bad one from a purely objective design perspective). |
|
How do you access the item in a 2D array represented on a flat array? my_array[x+ywidth]
But what is all that starts at 1? my_array[x+(y-1)width]
I did a lot of code in both systems and I remember distinctly that 1.. indexing just was more work to do, in turn bringing in more off by 1 bugs.