Better organized
This commit is contained in:
21
luprex/syslua/tableutil.lua
Normal file
21
luprex/syslua/tableutil.lua
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user