lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


A minor correction:

local foo = {
  bar = function(self, meh)
     return self.x .. meh
  end,
  x = "hey "
}
local foosmethod = foo:bar
print(foosmethod("dude"))
-- >> "hey dude"
foo = nil
print(foosmethod("dude"))
-- simple: >> "hey dude"
-- object ownership: >> error: attempt to call 'foosmethod' (a nil value)
-- weak upvalue: >> error: attempt to index 'self' (a nil value)