By using a numerical key, the table resembles an array data type. Lua arrays are 1-based: the first index is 1 rather than 0 as it is for many other programming languages (though an explicit index of 0 is allowed).

A simple array of strings:

array = { "a", "b", "c", "d" } -- Indices are assigned automatically.
print(array[2]) -- Prints "b". Automatic indexing in Lua starts at 1.
print(#array) -- Prints 4. # is the length operator for tables and strings.
array[0] = "z" -- Zero is a legal index.
print(#array) -- Still prints 4, as Lua arrays are 1-based.

The length of a table formula_1 is defined to be any integer index formula_2 such that formula_3 is not nil and formula_4 is nil; moreover, if formula_5 is nil, formula_2 can be zero. For a regular array, with non-nil values from 1 to a given formula_2, its length is exactly that formula_2, the index of its last value. If the array has "holes" (that is, nil values between other non-nil values), then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array).

An array of objects:

function Point(x, y) -- "Point" object constructor
end
array = { Point(10, 20), Point(30, 40), Point(50, 60) } -- Creates array of points
print(array[2].y) -- Prints 40

Using a hash map to emulate an array normally is slower than using an actual array; however, Lua tables are optimized for use as arrays to help avoid this issue.

As namespace
As array
As record
ସି ଆପ୍ଲିକେସନ ପ୍ରୋଗ୍ରାମିଂ ଇଣ୍ଟରଫେସ