Skip to content

Table Type

function table.create(n: number, value: any?): {any}
function table.insert(list: {any}, value: any)
function table.insert(list: {any}, position: number, value: any)
function table.remove(list: {any}, position: number?): any?
function table.move(source: {any}, sourceFrom: number, sourceTo: number, destPosition: number, destination: {any}?)
function table.clear(table: {any})
function table.pack(...: any): { [number]: any, n: number }
function table.unpack(list: {any}, from: number?, to: number?): ...any
function table.concat(list: {string}, separator: string?, from: number?, to: number?): string
function table.find(table: {any}, value: any, start: number?): number?
function table.sort(list: {any}, comparison: ((a: any, b: any) -> boolean)?)
function table.maxn(list: {any}): number
function table.freeze(table: table): table
function table.isfrozen(table: table): boolean
function table.clone(table: table): table
function table.shrink(table: table, reorder: boolean?): table

Tables can be used as arrays:

local example = {1,2,3,4}

Iterating an array:

for index, value in example do
print(index, value)
end

Tables can be used as dictionaries/maps:

local example = {key1 = "value1", key2 = "value2"}

Iterating a dictionary:

for key, value in example do
print(key, value)
end
function table.foreach<K, V, R>(t: { [K]: V }, f: (K, V) -> R?): R?
function table.foreachi<V, R>(t: {V}, f: (number, V) -> R?): R?
function table.getn<V>(t: {V}): number