18 lines
1.2 KiB
Markdown
18 lines
1.2 KiB
Markdown
## Return Statement
|
|
|
|
The return statement in AVAP is used to return the value of a desired variable from a function. Here is the syntax:
|
|
|
|
```javascript
|
|
return(variable_to_return):
|
|
```
|
|
|
|
Here is an overview of how the return statement works:
|
|
|
|
* Function Context: The return statement can only occur within a function definition, not inside a nested class definition.
|
|
* Variable Evaluation: If a variable is provided, it is evaluated. If no variable is specified, None is used by default.
|
|
* Function Exit: The return statement exits the current function call and returns the specified value.
|
|
* Interaction with try-finally: When the return statement is executed within a try statement that has a finally clause, the finally clause is executed before the function exits.
|
|
* Generator Functions: In generator functions, the return statement indicates the end of the generator. It causes a StopIteration exception to be raised, with the returned value (if any) used to construct the StopIteration exception and set as the StopIteration.value attribute.
|
|
|
|
The return statement is a fundamental part of functions and generators, allowing for the output of values and proper function termination.
|