Posted 03 July 2017 - 10:16 PM
Hello,
If i want to copy a table then I need something like this
If i want to copy a table then I need something like this
foo = function(tbl)
local ret = { }
for i, v in pairs(tbl)
if type(v) == "table" then
ret[i] = foo(v)
else
ret[i] = v
end
end
return ret
end
newTable = foo(oldTable)
because if I wont use this than
oldtable = { 1, 2, 3}
newtable = oldtable
newtable[2] = 5
-- newtable = {1, 5, 3}
-- oldtable = {1, 5, 3} <- !!!
now my question is, is there a default function or something else to disable that?