Re:Learn Lua in 15 Minutes (2013)
by nezirus on Wednesday July 01, 2020 @05:00AM
(#23699407)
If you want to treat your table (list) as integer indexed array (i.e. this is just called "array" in many other languages), and use length '#' operator, yes, you need to start at index 1, however, you can use 0 otherwise, or even strings.
Lua is a small language, and tables are the basic building blocks for arrays, dictionaries, classes, modules, ...
1-based indexing is IMHO a small price to pay for such flexible and efficient syntax, with small cognitive load)
Lua is a small language, and tables are the basic building blocks for arrays, dictionaries, classes, modules, ... 1-based indexing is IMHO a small price to pay for such flexible and efficient syntax, with small cognitive load)