CapsAdmin

Untitled

Sep 26th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.29 KB | None | 0 0
  1. local ref = {num = 1}
  2.  
  3. me.ref = ref
  4.  
  5. ref = nil
  6.  
  7. print(me.ref.num)
  8. >> 1
  9.  
  10. -- BAD!!!
  11.  
  12.  
  13.  
  14. local ref = {num = 1, Remove = function(self) self.valid = false end, IsValid = function() return true end}
  15.  
  16. me.ref = ref
  17.  
  18. ref:Remove()
  19.  
  20. print(me.ref:IsValid())
  21. >> false
  22.  
  23. -- good solution
Advertisement
Add Comment
Please, Sign In to add comment