Syntax
local tags = { "lua", "game" }
local user = { name = "Ada" }Examples
Reading a table
A small, runnable example of this syntax.
local user = { name = "Ada", active = true }
local tags = { "lua", "game" }
print(user.name)
print(tags[1])Best practices
- Use array-style tables for ordered sequences and named keys for records; do not rely on length behavior for tables with holes.
- Keep examples small while learning, then combine the idea with a real project.
At a glance
- Purpose
- Lightweight scripting and embedding
- File extension
- .lua
- Runs in
- Lua interpreter or a host application
- Usually used with
- Host APIs and Lua modules