[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible language extension: colon-notation in an expression as shorthand for instance-specific method
- From: junk <junk@...>
- Date: Tue, 27 Jan 2009 03:37:29 -0500
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)