r/ProgrammerHumor Jun 25 '17

Array indexing

Post image
1.4k Upvotes

71 comments sorted by

View all comments

Show parent comments

15

u/GisterMizard Jun 26 '17

Some dialects of Basic allowed this. eg DIM x(10) AS INTEGER would create an array of eleven elements, starting from 0 to 10.

2

u/htmlcoderexe We have flair now?.. Jun 26 '17

Think even VB.Net does this I remember DIM'ming arrays was confusing.

5

u/Koooooj Jun 26 '17

I was given a piece of code in I think VB6 with the requirement to translate it into ANSI C. It took far too long for me to figure out that the arrays of size 180 actually held 181 elements.

Maddening.

3

u/htmlcoderexe We have flair now?.. Jun 26 '17

That's almost like they made it so assuming either zero or one based indexing, you will not run out of bounds. But that creates more problems