Return
On this page

Return()

Function in Authoring

Push an explicit return value; onto the innermost scope.

import { Return } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

const Return: (value?: ReadonlyNode) => void

Parameters

valueoptional ReadonlyNode

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))

In the guide

See also

Source

src/core/ir/builder.ts, line 1704, at commit 26de7be8

Edit this page Report a problem