Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

spread

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Spreads an array or collection literal into its surrounding expression.

Aliases: ...

Syntax: spread <expression>

Category#

list

Examples#

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

Spreads an array or collection literal into its surrounding expression.

# =============================================================================
# spread — 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 spread (splice) with appende, or using spread on a non-collection expression
#
# See also: list
# =============================================================================

# spread — spread a collection into another collection or call
#
# [a, spread <list>, b]           -- splice into list literal
# fn(spread <list>)          -- spread call arguments
#
# GRAMMAR:
#   spargeExpr :← 'spread' expr
#
# EXPECTED OUTPUT:
#   1, 2, 3, 4 (expanded list elements).

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

Expected output:

1
2
3
4