渲染zh-Hant

流

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

Callable posture for synchronous stream (generator) functions.

Aliases: generator

Syntax: 函式 name(…) 流 → T

Category#

async

Examples#

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

Callable posture for synchronous stream (generator) functions.

# =============================================================================
# 流 — Synchronous stream callable posture
# =============================================================================
#
# What this teaches:
#   • Preferred stream posture: `流 → T` yields `T` items.
#   • Yield with statement-initial `讓出 value` inside the body.
#
# Common mistakes:
#   • Using `@ 迭代器` only when teaching preferred morphology — prefer `流`.
#
# See also: 迭代器, 讓出, 異流
# =============================================================================

# GRAMMAR:
#   callablePosture :← '流'
#   yieldStmt :← '讓出' expr
#
# EXPECTED OUTPUT:
#   [1, 2]

函式 stream() 流 → 整數 {
    讓出 1
    讓出 2
}

入口 {
    註記 stream()
}

Expected output:

[1, 2]