渲染zh-Hant

等變

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Awaits a 承諾 and binds a mutable name.

Aliases: await_var

Syntax: 等變 T name ← future

Category#

async

Examples#

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

Awaits a 承諾 and binds a mutable name.

# =============================================================================
# 等變 — Await-bind mutable
# =============================================================================
#
# What this teaches:
#   • Await a `承諾<T>` and bind the success value mutably.
#
# See also: 等定, 等棄, 異步, 承諾
# =============================================================================

函式 responde() 異步 → 整數 {
    傳回 3
}

非同步入口 {
    等變 整數 responsum ← responde()
    responsum ← responsum + 1
    註記 responsum
}

Expected output:

4