nhường
Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.
Yields one value from a generator.
Aliases: yield
Syntax: nhường <expression>
Category#
async
Related#
Examples#
radix/corpus/cede/cede.fab (canonical · keyword)#
Yields one value from a generator.
# =============================================================================
# nhường — Yields one value from a generator.
# =============================================================================
#
# What this teaches:
# • Yield — `nhường <expression>` emits one item from a `sinh` or `async_sinh`
# callable
# • Async values use `đợi_hằng`, `đợi_biến`, `đợi_trả`, or `đợi_bỏ`; `nhường`
# is not an await form
#
# Common mistakes:
# • using `nhường` outside a generator body
#
# See also: con_trỏ, sinh, async_sinh
# =============================================================================
# nhường — yield from a stream function
#
# hàm stream() sinh → T { nhường value }
#
# GRAMMAR:
# yieldStmt :← 'nhường' expr
#
# EXPECTED OUTPUT:
# [1, 2]
#
# BACKEND:
# Cursor stream materialization smoke.
fn stream() generator → int {
yield 1
yield 2
}
main {
print stream()
}Expected output:
[1, 2]