Are you a programmer or did this subreddit get randomly recommended to you?
Anyway, an array is a list of elements in a sequence, usually represented by brackets, so:
[10, 5, 7, 2, 1] is an array with 5 integers.
In programming, more often than not, array counting starts at 0, so the 0th number here would 10, 1st would be 5, 2nd is 7, etc.
Lua is a programming language that this counting starts at 1 instead of 0, which although is more intuitive for most people, it isn't for experienced programmers
That's how arrays usually behave. If you want something dynamic, that requires constant reallocation to resize, which isn't always desireable. At a low level, arrays don't even exist. It's just raw memory. And in order for arrays to keep growing, you have to keep moving them to new places in memory that have enough space to hold all of the elements. Normally, the array grows by a factor of 2 upon resizing so that the next resize is further away each time.
View all comments
Show parent comment
3
u/MrHellYe 13d ago
Are you a programmer or did this subreddit get randomly recommended to you?
Anyway, an array is a list of elements in a sequence, usually represented by brackets, so:
[10, 5, 7, 2, 1] is an array with 5 integers.
In programming, more often than not, array counting starts at 0, so the 0th number here would 10, 1st would be 5, 2nd is 7, etc.
Lua is a programming language that this counting starts at 1 instead of 0, which although is more intuitive for most people, it isn't for experienced programmers