/
Lua table as list

Lua table as list

Tables can be used as arrays, functioning much like a list. Try copy pasting this code into the translator:

local Primes = {1,2,5,7,11,13,17} trace(Primes); trace(#Primes); for i=1, #Primes do trace(i); end

Putting the # Operator on Lua Tables gives the number of elements in the array.

As you can see, it’s quite straightforward to use the number of elements in the array in afor loop to iterate through an table like this:

Next, see Lua tables as dictionaries.

 

 

Related content

Value Types
More like this
Annotation Windows
Annotation Windows
Read with this
Lua tables as dictionaries
Lua tables as dictionaries
More like this
Creating a JSON Filter
Creating a JSON Filter
Read with this
for in loop
More like this
table:remove()
table:remove()
Read with this