0Pricing
Lua Academy · Lesson

table Library Functions

Apply table.insert, remove, sort, concat, move, and unpack.

The table Module

The table module provides functions to manipulate Lua tables used as arrays: insert, remove, sort, concat, move, and unpack.

table.insert

table.insert(t, val) appends to the end. table.insert(t, pos, val) inserts at position, shifting later elements right.

local t = {"a", "b", "d"}
table.insert(t, "e")       -- append
table.insert(t, 3, "c")   -- insert at index 3
print(table.concat(t, ","))  -- a,b,c,d,e

All lessons in this course

  1. math Library Functions
  2. table Library Functions
  3. os and io Libraries
  4. The debug Library
← Back to Lua Academy