In some calling of function we use "." operator while in some we use ":" what is the difference between them.
Example:storyboard:addEventLsitener(something,something)
graphics.newImageSheet(something,something)
Asked
Active
Viewed 370 times
1

Javasamurai
- 666
- 7
- 21
-
3Please see http://stackoverflow.com/questions/4911186/difference-between-and-in-lua – James Curtis Mar 21 '14 at 17:03
-
This is a duplicate, please close. – Oliver Mar 21 '14 at 21:25
2 Answers
5
foo:bar(...)
is syntactic sugar for foo.bar(foo, ...)
, i. e. that's the "traditional" object-oriented syntax. The .
operator only accesses a member of a table as normal, without doing anything special when used in conjunction with a function call, whereas :
sets the self
argument of the called function.

user3447428
- 125
- 4
2
storyboard:addEventLsitener(a,b)
is sugar for storyboard.addEventLsitener(storyboard,a,b)
.

lhf
- 70,581
- 9
- 108
- 149