Does setting a table index to nil actually remove the value, if its a function?

Lets say you have a function inside a table, in this case ill put it in a module

local module = {}

module.Fire = function()


return module

Lets say i do this

module.Fire = nil

Does it remove/garbage collect the function

If you need me to explain more dont hestitate to ask

Yes, it is garbage collected if no other references are pointing to that block of memory because it is an anonymous function (lambda). So the memory block would be stale and eventually garbage collected; but if other things reference that memory block outside of the module then setting it to nil will not garbage collect that anonymous function.

1 Like

Thanks for your help. You explained better than the last post