http://lua-users.org/wiki/ObjectOrientationTutorial
Method declarations
Likewise there is syntactic sugar for method declarations. Regardless how it is declared, a method expects that first argument passed in is the object to be acted on. If a dot is used (i.e. t.foo(self, args)) we declare self ourselves. If a colon is used (i.e. t:foo(args)) self will be declared automatically for us.
> t = {}
> function t.foo(self,x) print(self,x) end – no sugar, explicit self
> function t:foo2(x) print(self,x) end – sugar and magic self
>
> t.foo(t,1) – is the same as…
table: 0035D830 1
> t:foo2(1) – shorthand for above
table: 0035D830 1
And reversed:
> t:foo(1) – the same as…
table: 0035D830 1
> t.foo2(t,1)
table: 0035D830 1
[import]uid: 6645 topic_id: 4292 reply_id: 13334[/import]