Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/components/collection-literals.x

Array and Map literals.

Functions

FunctionSummary
array_literalBuilds an Array literal from its elements.
map_literalBuilds a Map literal from its keys and values, alternating.

Functions

array_literal

meta Code array_literal(Code code)

Builds an Array literal from its elements.

Source: src/components/collection-literals.x:14

map_literal

meta Code map_literal(Code code)

Builds a Map literal from its keys and values, alternating.

Source: src/components/collection-literals.x:32

Design notes

A collection literal builds its container with the counted constructor, which receives each element converted to Var, in source order; an empty brace among the elements is an empty Map. The compiler keeps the elements in source order; see src/transform/literals.x.