Return()
Function in Authoring
Push an explicit return value; onto the innermost scope.
import { Return } from 'typeshade/core/ir'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
const Return: (value?: ReadonlyNode) => voidParameters
valueoptionalReadonlyNode
Return value
void
Description
Use it
for any return from inside If, Loop or Switch control flow: a native JavaScript
return inside a nested body callback only exits that closure and emits nothing, so what
reads as an early exit falls through. The one place a native return value works is a
body’s own final, top-level return, which fn() appends for you. For the common “return
early if a condition holds” shape, ReturnIf is the more readable guard-clause
spelling.
Examples
Example
If(winding.ne(0), () => { Return(f32(1).sub(min_dist))})Return(f32(1).add(min_dist))See also
Source
src/core/ir/builder.ts, line 1427, at commit af54ddad5