luaguides

Reference

Table Methods

Methods for table manipulation.

  1. table.concat

    table.concat joins a Lua list of strings and numbers into a single string, with an optional separator and index range.

  2. table.insert

    Insert a value into a Lua table at a given position, shifting later elements up. Without a position, table.insert appends to the array part of the table.

  3. table.maxn (deprecated)

    table.maxn returns the largest positive numeric key in a table. Deprecated in Lua 5.2, removed in 5.3; use # or a pairs() loop.

  4. table.move

    table.move copies a contiguous range of elements from one table to another, with optional in-place mode and correct handling of overlapping ranges.

  5. table.pack

    table.pack captures Lua varargs into a table with an n field that preserves the true argument count even when values are nil.

  6. table.remove()

    table.remove() removes and returns an element from a Lua sequence, with an optional index. Trailing elements shift down to close the gap.

  7. table.sort

    table.sort reorders a Lua sequence in place using the < operator by default. Pass an optional comparator to customize ordering or sort complex elements.