Last active
April 9, 2024 00:22
-
-
Save Fraktality/f0ab4ad950698e9f08bb01bea486845e to your computer and use it in GitHub Desktop.
Some people just want to watch the world burn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Dumpster = {} do | |
Dumpster.__index = Dumpster | |
local finalizers = setmetatable( | |
{ | |
["function"] = function(item) | |
return item() | |
end, | |
["Instance"] = game.Destroy, | |
["RBXScriptConnection"] = Instance.new("BindableEvent").Event:Connect(function() end).Disconnect, | |
}, | |
{ | |
__index = function(self, className) | |
error(("Can't dump item of type '%s'"):format(className), 3) | |
end, | |
} | |
) | |
function Dumpster.new() | |
return setmetatable({}, Dumpster) | |
end | |
function Dumpster:dump(item) | |
self[item] = finalizers[typeof(item)] | |
return item | |
end | |
function Dumpster:burn() | |
for item, finalizer in pairs(self) do | |
finalizer(item) | |
end | |
table.clear(self) | |
end | |
end | |
return Dumpster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment