Skip to content

Instantly share code, notes, and snippets.

@shakesoda
Created November 17, 2013 23:14
Show Gist options
  • Save shakesoda/7519601 to your computer and use it in GitHub Desktop.
Save shakesoda/7519601 to your computer and use it in GitHub Desktop.
util for merging lotsa tables
function merge(t1, t2)
for k,v in pairs(t2) do
if type(v) == "table" then
if type(t1[k] or false) == "table" then
tableMerge(t1[k] or {}, t2[k] or {})
else
t1[k] = v
end
else
t1[k] = v
end
end
return t1
end
function multi_merge(...)
local args = {...}
local ret = {}
for _, v in pairs(args) do
merge(ret, v)
end
return ret
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment