July 2018
Beginner
202 pages
5h 42m
English
In the previous section, you implemented some object-oriented principles by building an enemy class, instantiating several enemies and calling some methods on the enemy instances. While all of the code was technically correct, each enemy instance had to be passed to the function stored in the enemy class.
Lua provides some syntactic sugar for calling functions on objects, the colon (:) operator.
This operator automatically provides the first argument to a function. This first argument, by convention, is called self. You can call this first argument whatever you want, but following convention will make your code easy to read and maintain.
The following bit of code demonstrates how the colon operator is used in comparison to ...