|
| 09 Jul 2014 11:46 AM |
Like one function might be :Remove() and another .Remove()
Is it because the function is after/before the argument? |
|
|
| Report Abuse |
|
|
| |
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 09 Jul 2014 11:52 AM |
| I have never seen people use .Thing() before |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 11:54 AM |
| Oh right, so : is always followed by the function name? |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
|
| 09 Jul 2014 11:55 AM |
':' gives a first argument of 'self'
Quick example:
game.Destroy(workspace.Base)
is same as
workspace.Base:Destroy() |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 11:56 AM |
"':' gives a first argument of 'self'"
That is not true at all. |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 09 Jul 2014 11:58 AM |
Yes it is.
table.function(self, arg) == table:function(arg) |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 11:59 AM |
local t = { f = function(a) print(a) end }
t.f() t:f()
So yes, it is 100% true. |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 11:59 AM |
Oh I see, thanks for the help.
I'd rather use the : as it is easier to understand |
|
|
| Report Abuse |
|
|
| |
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
|
| 09 Jul 2014 12:00 PM |
Another example to better explain it:
local t = { method = function(self) print(self == t) end }
t:method() > true -- self is the table t
t.method() > false -- self is nil |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 12:01 PM |
| I already tested it myself you can stop posting examples now. |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 12:02 PM |
@ox You'll have to make 't' an upvalue in that case, because t.method cannot actually access t itself unless you use the self parameter.
Just a small nit-picky thing. :P |
|
|
| Report Abuse |
|
|