[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Create a new table based on an already existed table (through Lua or C API)?
- From: 孙世龙 sunshilong <sunshilong369@...>
- Date: Thu, 21 Jan 2021 11:25:56 +0800
How to create a new table based on an already existed table (through
Lua or C API)?
This code snippet seems impossible to achieve this goal:
foo = {};
foo.a = 1;
foo.b = 2;
new = foo;
print(new, foo) --they both point to the same table!
new.a = new.a+1; --the value of foo.a has been modified too.
--I hope the table named `new` to be a
table which is independent from the table named `foo`.