Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR LUA

copy table lua

function copy(obj, seen)
  if type(obj) ~= 'table' then return obj end
  if seen and seen[obj] then return seen[obj] end
  local s = seen or {}
  local res = setmetatable({}, getmetatable(obj))
  s[obj] = res
  for k, v in pairs(obj) do res[copy(k, s)] = copy(v, s) end
  return res
end
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #table #lua
ADD COMMENT
Topic
Name
2+3 =