View Single Post
  #18  
Unread 05-21-2018, 02:02 PM
Thurallor's Avatar
Thurallor Thurallor is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: May 2013
Posts: 202
Code:
Turbine.Engine.GetLocale();
Turbine.Engine:GetLocale();
Since the function takes no arguments, the two are effectively the same. In the second case, Turbine.Engine is implicitly passed as the first argument. So, the following two are exactly equivalent:

Code:
Turbine.Engine:GetLocale();
Turbine.Engine.GetLocale(Turbine.Engine);
There is a corresponding shorthand that can be used when defining functions. From the Lua 5.1 manual:

Quote:
The colon syntax is used for defining methods, that is, functions that have an implicit extra parameter self. Thus, the statement
function t.a.b.c:f (params) body end
is syntactic sugar for
function t.a.b.c.f (self, params) body end

Last edited by Thurallor : 05-21-2018 at 02:08 PM.
Reply With Quote