Also, "self" is simply syntactic sugar.
Code:
local foo = {}
foo.bar = function(self)
-- Do something with self.
end
function foo.bar(self)
-- Do something with self
end
function foo:bar()
-- Do something with self
end
Dot-notation means you must explicitly pass in the table as 'self'. Colon-notation does so implicitly. The following examples are equivalent:
Code:
local baz = foo.bar(foo)
baz = foo:bar()