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

กระจาย

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

Spreads an array or collection literal into its surrounding expression.

Aliases: ...

Syntax: กระจาย <expression>

Category#

collection

Examples#

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

Spreads an array or collection literal into its surrounding expression.

# =============================================================================
# กระจาย — Spreads an array or collection literal into its surrounding expression.
# =============================================================================
#
# What this teaches:
#   • Spread syntax — how to splice a collection into a list literal or function call
#   • Collection composition — building larger expressions by expanding collections inline
#
# Common mistakes:
#   • confusing กระจาย (splice) with appende, or using กระจาย on a non-collection expression
#
# See also: รายการ
# =============================================================================

# กระจาย — spread a collection into another collection or call
#
# [a, กระจาย <รายการ>, b]           -- splice into list literal
# ฟังก์ชัน(กระจาย <รายการ>)          -- spread call arguments
#
# GRAMMAR:
#   spargeExpr :← 'กระจาย' expr
#
# EXPECTED OUTPUT:
#   1, 2, 3, 4 (expanded list elements).

main {
    const list<int> media ← [2, 3]
    # → [1, 2, 3, 4]
    const list<int> numeri ← [1, spread media, 4]
    for from numeri const n {
        print n
    }
}

Expected output:

1
2
3
4