Add table.clear

This commit is contained in:
Lars Mueller 2022-09-30 15:31:11 +02:00
parent 94cbfe30eb
commit 8b538587ad

@ -400,6 +400,12 @@ function is_empty(table)
return next(table) == nil return next(table) == nil
end end
function clear(table)
for k in pairs(table) do
table[k] = nil
end
end
function foreach(table, func) function foreach(table, func)
for k, v in pairs(table) do for k, v in pairs(table) do
func(k, v) func(k, v)