We use cookies on this site to enhance your user experience

Weak Values

Weak Values

local t = {}
setmetatable(t, {__mode = "v"}) -- Set the values as weak

do -- Create a new scope
	-- Create a new object in this scope, 
	-- so the object can be garbage collected.
	local newValue = newproxy(true) 
	t[1] = newValue
end

collectgarbage()
print(t[1])