การเรนเดอร์th-TH

ให้

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.

Yields one value from a generator.

Aliases: yield

Syntax: ให้ <expression>

Category#

async

Examples#

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

Yields one value from a generator.

# =============================================================================
# ให้ — Yields one value from a generator.
# =============================================================================
#
# What this teaches:
#   • Yield — `ให้ <expression>` emits one item from a `สตรีม` or `สตรีมอะซิงก์`
#     callable
#   • Async values use `รอคง`, `รอแปร`, `รอคืน`, or `รอทิ้ง`; `ให้`
#     is not an await form
#
# Common mistakes:
#   • using `ให้` outside a generator body
#
# See also: เคอร์เซอร์, สตรีม, สตรีมอะซิงก์
# =============================================================================

# ให้ — yield from a stream function
#
# ฟังก์ชัน stream() สตรีม → T { ให้ value }
#
# GRAMMAR:
#   yieldStmt :← 'ให้' 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]