## Return

The return statements can be used in three contexts:

• Inside a function, where it exits the function and returns a value:
def f (){
return 42
}
value = f()
• Inside a function, to exit the function without returning values:
def f(cond) {
if(cond)
return
// continue ...
}
• In the top level of a script, where it stops the script execution and returns the script value:
def a = 1
return 1

Any value can be returned in the case of a function return.

In the case of a script return, the returned value can be:

• A floating point
• An array
• A matrix
• A cube

Note that changing the return type of a script may require code modification (either in the hard coded technical stack you are using, or in the box code if you are using workflows).

When you want to obtain the output of your code, you need to insert return in your .psl file, as shown below:

def x = 5
def y = 0
def z = 10

if (z < 15){
y = x * x
}

return y

In this case, if you execute your run command, you obtain 25 in the console.

Remember that, apart from giving the output of a function or a script, return also signalizes the end of the script execution.