Better organized

This commit is contained in:
2020-11-13 15:18:09 -05:00
parent 0c723bf17d
commit 9523e367f1
10 changed files with 207 additions and 98 deletions

View File

@@ -0,0 +1,21 @@
-- Coerce T to be a table.
-- If T is a table, return it. If not, return a blank table.
function table.coerce(t)
if type(t) == "table" then
return t
else
return {}
end
end
-- Clear the table out. Deletes all keys, removes any metatable.
-- TODO: this doesn't work on tables that have __metatable metamethod.
function table.rawclear(t)
for k in pairs(t) do
rawset(t, k, nil)
end
setmetatable(t, nil)
return t
end