Skip to content

Inline functions

Jordan Leppert edited this page Apr 28, 2024 · 3 revisions

Inline functions are functions that can be declared within in your script. This lets you apply the same function multiple times within your script without needing to create an external user-defined function.

Declaration

An inline function is defined by entering statements between curly braces: { and }. A reference to the function should be stored in a variable.

Input

All input parameters are put into the variables PARAM1, PARAM2 etc.

Output

The final statement of the inline function is the output.

f = {
    # Returns the first parameter multiplied by 2
    PARAM1 * 2
}

Execution

Similar to user-defined functions, inline functions are executed by entering @ followed by the variable name containing the reference to the inline function, followed by brackets containing the parameters to the function.

# Will execute the inline function stored in variable f, with the parameter 4
@f(4)