Syntax
local user = { name = "Ada", active = true }
print(user.name)Examples
Lua keyed tables example
A focused example you can adapt while practising.
local user = { name = "Ada", active = true }
print(user.name)Best practices
- Start with the smallest working example, then adapt it to your project.
- Use the language’s standard library and idioms before introducing extra dependencies.
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
Specifications & further reading
Related Lua documentation
Lua Tables
Tables are Lua’s main compound data structure. They can act as arrays, dictionaries, objects, and namespaces; indexes begin at 1 by convention for sequences.Lua array-style tables
Lua reference for lua array-style tables.Lua table.insert and remove
Lua reference for lua table.insert and remove.Lua length operator
Lua reference for lua length operator.
Tables are Lua’s main compound data structure. They can act as arrays, dictionaries, objects, and namespaces; indexes begin at 1 by convention for sequences.Lua array-style tables
Lua reference for lua array-style tables.Lua table.insert and remove
Lua reference for lua table.insert and remove.Lua length operator
Lua reference for lua length operator.