Renderingen-US

return_await

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Awaits a promise and returns its success value from a async body.

Aliases: return_await

Syntax: return_await future

Category#

async

Examples#

radix/corpus/reddet/reddet.fab (canonical · keyword)#

Awaits a promise and returns its success value from a async body.

# =============================================================================
# return_await — Await-return
# =============================================================================
#
# What this teaches:
#   • Await and return from a `async` function only (`return_await future`).
#
# See also: await_const, await, async, return
# =============================================================================

fn interior() async → int {
    return 9
}

fn exterior() async → int {
    return_await interior()
}

async_main {
    await_const int v ← exterior()
    print v
}

Expected output:

9