Code: Select all
table.remove(the table I want to delete the content of)
Code: Select all
table.remove(the table I want to delete the content of)
Code: Select all
thetable = {}
Code: Select all
for i,v in ipairs(table) do
table.remove(table, i)
end
Code: Select all
mytable = {}
Code: Select all
for k, v in pairs(mytable) do
mytable[k] = nil
end
Thanks, this worked perfectly!Automatik wrote:Code: Select all
thetable = {}
Code: Select all
for i = #tab,1,-1 do
tab[i] = nil
end
That is not true for next (and therefore pairs), you just can't add, but you can delete, according to the manual:raidho36 wrote:You can't delete and add keys in looping a table throuh the iterator. That is, you can, but under such conditions behavior is undefined.
The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 5 guests