当前位置:网站首页>lua-复制一份table,修改新的table,不改变原来的table
lua-复制一份table,修改新的table,不改变原来的table
2022-08-11 05:31:00 【星际行走】
local table1 = {
{1,2,3}, {4,5,6}}
local table2 = UITools.CopyTable(table1)
table2[1][1] = 2
print("table1 =", PrintTable(table1))
print("table2 =", PrintTable(table2))-- 复制一份table,修改不会影响原来的表
function UITools.CopyTable(table1)
local newTable = {}
for key, value in pairs(table1) do
if type(value) == "table" then
newTable[key] = UITools.CopyTable(value)
else
newTable[key] = value
end
end
return newTable
end边栏推荐
猜你喜欢

js learning advanced BOM part (pink teacher notes)

buuctf hacknote

Unity Mesh、MeshFilter、MeshRenderer扫盲

ARM assembly instruction ADR and LDR

js learning advanced (event senior pink teacher teaching notes)

JS advanced web page special effects (pink teacher notes)

Getting Started with JNI

C# 基础之字典——Dictionary(一)

5月leetcode-C#刷题日志(持续更新中)

【LeetCode-69】x的平方根
随机推荐
【LeetCode-414】第三大的数
IO流和序列化与反序列化
Tinker's self-introduction
He Kaiming's new work ViTDET: target detection field, subverting the concept of layered backbone
Byte (byte) and bit (bit)
PyQt5中调用.ui转换的.py文件代码解释
Day 81
swagger常用注释API @ApiModel、@ApiModelProperty的用法
OpenMLDB: Consistent production-level feature computing platform online and offline
OpenGL WSAD按键操作和鼠标移动操控摄像机Camera类
Scene-driven feature calculation method OpenMLDB, efficient implementation of "calculate first use"
Unity C# 面试题、知识点总结
Pinyougou project combat notes
C语言实现扫雷游戏
heap2 (tcache attack,house of orange)
【LeetCode-56】合并区间
The mount command - mounted read-only, solution
C语言-7月22日- NULL和nullptr的深入了解以及VScode对nullptr语句报错问题的解决
PAT乙级刷题之路
Day 76