/
Colon Operator

Colon Operator

The Colon Operator (“:”) is a shorthand syntax used for calling methods on objects.

When you use the colon syntax to call a function, the object (the “self”) is automatically passed as the first argument to the function.

For example…

local Fruit = "Apple,Banana,Orange" local List = string.split(Fruit, ",") trace(List)

is equivalent to:

local Fruit = "Apple,Banana,Orange" local List = Fruit:split(",") trace(List)

 

Related content

String:sub()
More like this
String:split()
String:split()
More like this
Concatenating strings
Concatenating strings
More like this
# Operator on Strings
# Operator on Strings
More like this
table:insert()
table:insert()
More like this
How does the function returned from pairs work?
How does the function returned from pairs work?
More like this