Table

A table is an implementation of a map. That is, it associates several keys with values, both being of arbitrary type, with the exception of nil. Should a table be indexed by a key that is not associated with a value, it will yield nil. Vice-versa, assigning nil to a key will delete it. Tables are Lua's only way of describing complex data structures, such as records and arrays.

Syntax
A table literal is formatted as two corresponding swirly brackets, containing comma-separated key-value pairs formatted like. To index a table, we use square brackets after the table expression containing an expression that evaluates to the key, such as.

Records
In Lua, records are created by associating string keys with arbitrary-type values. For convenience, in the case of string keys only, the square brackets and quotation marks in the key-value pair definition may be omitted. Additionally, string-keyed tables may be indexed using the  syntax.

Arrays
In Lua, arrays are represented as a table of values with consecutive numeric keys, starting at 1, as seen above. To simplify the creation of arrays, the keys may be omitted altogether, which will instruct Lua to automatically assign ascending numeric indices to the values. Thus, the aforementioned example can be rewritten as such: