create table.deep_copy

This commit is contained in:
Xertis 2024-12-09 18:33:45 +03:00 committed by GitHub
parent a2bf2bc1a1
commit c5033dc6ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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