当前位置:网站首页>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边栏推荐
猜你喜欢

微信小程序启动页的实现

The whole process of Tinker access --- configuration

Node stepping on the pit 80 port is occupied

Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain

CLR via C# 第一章 CLR的执行模型

Intelligent risk control China design and fall to the ground

自己动手写RISC-V的C编译器-01实现加减法

Matplotlib找不到字体,打印乱码

Asis2016 books null off by one

基于微信小程序云开发实现的电商项目,可以自行定制开发
随机推荐
Unity Mesh、MeshFilter、MeshRenderer扫盲
Tinker's self-introduction
C语言-7月21日-指针的深入
Unity 使用双缓冲实现一个好用的计时器
IO流和序列化与反序列化
Lua 快速入门(二)——函数(Function)
C语言-内存操作函数
【LeetCode-73】矩阵置零
JVM学习四:垃圾收集器与内存回收策略
nepctf Nyan Cat 彩虹猫
Manufacturer Push Platform-Huawei Access
js learning advanced (event senior pink teacher teaching notes)
【LeetCode-455】方法饼干
127.0.0.1 connection refused
【LeetCode-349】两个数组的交集
【LeetCode-69】x的平方根
【LeetCode-205】同构字符串
Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched
2022DASCTF X SU 三月春季挑战赛 checkin ROPgadget进阶使用
微信小程序云开发项目wx-store代码详解