Table (as an array)
Try it yourself →Ordered values (indexed from 1!).
Syntax
t = {e1, e2, e3}Description
The only structure in Lua is the table. When used as an array, the index starts at 1. #t gives the number of elements.
Example
local t = {10, 20, 30}
print(t[1])
print(#t)Expected output
10 3
When to use?
Storing lists.
Common mistakes
- ⚠️ The first element in Lua is t[1], not t[0]!