mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
create table.deep_copy
This commit is contained in:
parent
a2bf2bc1a1
commit
c5033dc6ff
1 changed files with 11 additions and 1 deletions
|
|
@ -56,9 +56,19 @@ end
|
|||
function table.copy(t)
|
||||
local copied = {}
|
||||
|
||||
for k, v in pairs(t) do
|
||||
copied[k] = v
|
||||
end
|
||||
|
||||
return copied
|
||||
end
|
||||
|
||||
function table.deep_copy(t)
|
||||
local copied = {}
|
||||
|
||||
for k, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
copied[k] = table.copy(v)
|
||||
copied[k] = table.deep_copy(v)
|
||||
else
|
||||
copied[k] = v
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue