Hello everyone! My question is pretty simple. I want to remove a table so everywhere where it’s referenced it was set to nil. Something like this:
local data = {
key = {}
}
local table_reference = data[key]
*removing table_reference*
print(data) -> {key=nil}
Note: tables I want to remove are metatables. Also table.clear() doesn’t work cuz it just keeps empty table.
1 Like
You can do it like this:
data[key] = nil
setting the object to nil will remove it from the dictionary table.
You MIGHT be able to do
table_reference = nil
Though I doubt that would work
1 Like
NOVEIGMA
(NOVEIGMA)
3
Only works when that variable is the only reference to the table, in that case the table gets marked as untracked memory and gets wiped by GC later
Example:
local a = {}
local b = a
a = nil
--table still exists as the variable "b"
b = nil
--now the table is untracked and will be cleaned by GC
4 Likes
system
(system)
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.