Created
May 12, 2013 02:23
-
-
Save cha55son/5562163 to your computer and use it in GitHub Desktop.
Simple function that will recursively extend lua tables.
This file contains 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 extend(table1, table2) | |
for k,v in pairs(table2) do | |
if (type(table1[k]) == 'table' and type(v) == 'table') then | |
extend(table1[k], v) | |
else | |
table1[k] = v | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is pretty old, but if any one else stumbles upon it... the method needs to
return table1
and then it seems to work as expected