View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Mar 07, 2017 4:02 pm Post subject: Resetting a table in Lua? |
|
|
Say, if I have a table
Is there a method like "table.clear()" in Lua to clear all the data in a table? Or do I have to do it manually, which means iterating through the whole table?
Thanks.
Edit:
What if I do this? Will it cause memory leak?
Code: |
table = {}
function test1()
local t = {1,2}
table = t
end
function test2()
local t = {3,1}
table = t
end
|
If I call "test1()" then "test2()", the data in "table" should be "3" and "1", right? If so, is there any memory leak? Is "table" only a pointer or not? _________________
**************
A simple example is better then ten links.
Last edited by Dr.Disrespect on Tue Mar 07, 2017 4:09 pm; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Mar 07, 2017 4:07 pm Post subject: |
|
|
table={} will clear all fields inside it. (basically it assigns a new empty table to that variable} _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Mar 07, 2017 4:09 pm Post subject: |
|
|
Dark Byte wrote: | table={} will clear all fields inside it. (basically it assigns a new empty table to that variable} |
Thanks a lot, DB. _________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
|