~/Lua Table Quick Guide
Mar 12, 2023
Lua tables are the main data structure for arrays, dictionaries, and objects.
Creating a table Use curly braces to create a table.
Accessing values Use square brackets or dot notation.
Modifying values Add or update entries by assignment.
Iterating a table
Use pairs
for key-value pairs, ipairs
for arrays.
Removing values Set the key to nil.
|
|
Table length
Use #
for array-like tables.
|
|
Metatables Tables can have metatables for custom behaviors.
Lua tables are flexible and serve as building blocks for all data structures. More details at the official Lua manual.