Functions

Functions are ways to group instructions. A function can carry out a task, or it can compute something and return a result. A function can also receive parameters. These parameters are variables, and can be used in the function body.

What Does a Function Look Like?

Here is an example of a function:

ifig0013.jpg

A function can also be expressed as:

ifig0014.jpg

The above two examples are of the same code, With two different syntaxes. The first version is the legacy way, and demonstrates that a function is like any other value. The second is a syntax shortcut. ...

Get Create 2D Mobile Games with Corona SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.