0

Is there a way of starting an array's index from 1 instead of 0?

5th Jun 2019, 7:58 PM
Samuel Anane-Kyei
Samuel Anane-Kyei - avatar
3 Answers
+ 3
Look at a centimeter measure - the first cm starts with 0 and ends with 1. Arrays are just the same.
5th Jun 2019, 9:43 PM
HonFu
HonFu - avatar
+ 2
No, there is nothing you can do about it. You could do index + 1 but then you're just wasting space. Lua starts at 1 though, but then again, it doesn't really use arrays but tables instead. Don't worry, you'll get used to it.
5th Jun 2019, 8:04 PM
Dennis
Dennis - avatar
+ 2
Matlab uses array indexing starting from 1. But the vast majority of programming languages index from 0
5th Jun 2019, 8:25 PM
Matthias
Matthias - avatar