Comment on page
Returns
The return statement allows you to early-return any body expression.
In functions this means that the following code will return "20" instead of "40"
double := fn(x) {
return 20
return 40
}
A return statement will only return the nearest block. Meaning that the following will not return it's outer function:
outer := fn(x) {
return fn() {
return 20
}()
}
Return statements will return the nearest function block, meaning the following example will cancel the for loop and return the function with the value 20.
function := fn() {
for (true) {
return 20
}
}
Last modified 1yr ago