FlowLang is built on the Rhai embedded scripting language. The language semantics on these pages are Rhai's; FlowLang adds the typed Connect- block surface on top (see the namespace catalogue).

Return Value

return

The return statement is used to immediately stop evaluation and exist the current context (typically a function call) yielding a return value.

return;             // equivalent to return ();

return 123 + 456;   // returns 579

A return statement at global level stops the entire script evaluation, the return value is taken as the result of the script evaluation.

A return statement inside a function call exits with a return value to the caller.

exit

Similar to the return statement, the exit function is used to immediately stop evaluation, but it does so regardless of where it is called from, even deep inside nested function calls.

fn foo() {
    exit(42);       // exit with result 42
}
fn bar() {
    foo();
}
fn baz() {
    bar();
}

let x = baz();      // exits with result 42

print(x);           // <- this is never run

The exit function is defined in the LanguageCorePackage but excluded when using a raw Engine.

FunctionParameter(s)Description
exitresult value (optional)immediately terminate script evaluation (default result value is ())