Functions

This is a central concept in writing good code. A function allows you to make a small piece of code which does one thing well and often can be reused if the same functionality is needed in multiple places. Functions apply a core design principal: separation of concerns.

Functions are Block statements.

function APPadd(a,b) local sum = a + b return sum end local sum = APPadd(2,3) -- returns 5
  • Arguments (ex. a,b) are variables which are used to pass data into a function.

  • Functions can return one or more values. Return ends function execution and returns the specified values to where the function was called.

See:

 

Related pages