水铁,拿经验!!!!

[复制链接]
查看1313 | 回复5 | 2021-8-20 08:26:16 | 显示全部楼层 |阅读模式
copyTable = function (table)
local lookup_table={}
local function _copy(table)
  if type(table) ~= "table" then
   return table
  elseif lookup_table[table] then
   return lookup_table[table]
  end
  local new_table = {}
  lookup_table[table] = new_table
  for index, var in pairs(table) do
   new_table[_copy(index)] = _copy(var)
  end
  return setmetatable(new_table,getmetatable(table))
end
return _copy(table)
end
回复

使用道具 举报

tenctry | 2021-8-20 08:45:14 | 显示全部楼层
水水水水水水水水水水
回复

使用道具 举报

风雷 | 2021-8-20 09:29:24 | 显示全部楼层
复制 table?  
水水水水,,我也来水一把.
  1. function DeepCopy(object)
  2.         local SearchTable = {}
  3.         1ocal function Func(object)
  4.                 if type(object) ~= "table" then
  5.                         return object
  6.                 end
  7.                 local NewTable = {}
  8.                 SearchTable [object] = NewTable
  9.                 for k, V in pairs(object) do
  10.                         NewTable[Func(k)] = FunC(v)
  11.                 end
  12.                 return setmetatable(NewTable, getmetatable(object))
  13.         end
  14.         return Func( object)
  15. end
复制代码
回复

使用道具 举报

cyx2004 | 2021-8-20 12:13:05 | 显示全部楼层
回复

使用道具 举报

fojiao1992 | 2021-8-20 12:38:16 | 显示全部楼层
l看不懂
回复

使用道具 举报

yexiaofeng45 | 2022-2-14 16:38:50 | 显示全部楼层
学习学习
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1

主题

15

帖子

127

积分

注册会员

Rank: 2

积分
127