Created
November 17, 2013 23:14
-
-
Save shakesoda/7519601 to your computer and use it in GitHub Desktop.
util for merging lotsa tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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