Arrays
Luau 0.731 · --!strict{T}A dense 1-based table whose elements share one type. Luau does not use a [] array literal.
When to use it
Read this page when you need to apply Arrays, verify its exact contract, and adapt the example without bypassing validation or host boundaries.
- An empty number array is local values: {number} = {}.
- Use #values and ipairs only for dense sequences without missing indexes.
Focused example
--!strict
local colors: {string} = { "red", "green" }
local labels: {string} = {}
table.insert(colors, "blue")
local first: string = colors[1]
for index, color in ipairs(colors) do
labels[index] = `{index}: {color}`
end
assert(first == "red" and labels[3] == "3: blue")