Return
All Arcade expressions must return a value. The permissible data types returned from an Arcade expression are defined by the profile. There are two types of return statements: explicit returns and implicit returns.
Explicit returns
An explicit return is always preceded with the return
keyword. This can be used for single-line expressions...
...and multi-line expressions.
It can also be used when defining functions.
Implicit returns
An implicit return returns the last executable statement of an expression. This is true regardless of an expression's length.
Although the return
keyword is not used in these multi-line expressions, the value of total
is still returned.
User-defined functions can also be written with an implicit return.
Guidelines
Expressions with explicit returns benefit from providing clarity to anyone reading it. When multi-line expressions lack an explicit return, it can be easily interpreted as incomplete or unfinished. The following are suggested guidelines when authoring expressions.
- Always use explicit returns when defining custom functions.
- Use implicit returns in single-line expressions.
- Always use explicit returns in multi-line expressions.