Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.36 KB | None | 0 0
  1. local MT = {}
  2. function MT:__gc()
  3.   self.cnt = self.cnt + 1
  4.   if self.cnt == 1 then
  5.     print("finalizing...")
  6.   else
  7.     print("and again...")
  8.   end
  9.  
  10.   setmetatable(self, MT) -- here the error occurs
  11. end
  12.  
  13. do
  14.   local Collectable = {cnt = 0}
  15.   setmetatable(Collectable, MT)
  16. end
  17.  
  18. collectgarbage()
  19. collectgarbage()
  20. collectgarbage()
  21. collectgarbage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement