Type Function Library table.* Return value Any Revision 2017.3060 Keywords table, array See also table.insert()
Removes from table the element at position pos, shifting down other elements to close the space, if necessary. Returns the value of the removed element.
table.remove( t ) table.remove( t, pos )
Table. The table from which to remove.
Number. Position of the element to remove. Its default value is the length of the table, so table.remove(t) removes the last element of t.
local exampleTable = { 1,1,2,3,5,8,13 }
print( table.maxn(exampleTable) ) --> 7
print( table.remove(exampleTable,4) ) --> 3
print( table.maxn(exampleTable) ) --> 6
print( table.remove(exampleTable) ) --> 13
local exampleTable = { 1,1,2,3,5,8,13 }
for i = #exampleTable,1,-1 do
table.remove(exampleTable,i)
end