3 ms·
It helps if you realize that there are no arrays in Lua. Instead, everything is an optimized hash map that can be indexed by any value of any type. A single tab
by bdowling 3y ago
It helps if you realize that there are no arrays in Lua. Instead, everything is an optimized hash map that can be indexed by any value of any type. A single table can have some elements indexed by integers, others indexed by strings, function pointers (useful for a table of debug hooks), etc.
The few convenient things that expect tables to be indexed using integers starting at 1 are the # operator to get the number of elements, and the ipairs function, used in the common idiom “for index, value in ipairs(t) do . . . end”.