How do I delete all elements inside a Lua table? I don\'t want to do:
t = {} table.insert(t, 1) t = {} -- this assigns a new pointer to t
I w
#table is the table size and so if t = {1,2,3} then #t = 3
#table
t = {1,2,3}
#t = 3
So you can use this code to remove the elements
while #t ~= 0 do rawset(t, #t, nil) end
You will go through the table and remove each element and you get an empty table in the end.