View Single Post
02-07-12, 02:32 PM   #19
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
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()
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote