Skip to content

Sym

Symbols are interned identifiers used for dictionary keys and enum-like values.

Creating Symbols

Literal syntax with surrounding colons:

let s = :my_symbol:

From a string with the lowercase sym coercion:

let s = sym "my_symbol"
assert_eq $s :my_symbol:

Enum-like values:

let status = :ok:
let mode = :verbose:

Dictionary keys:

let d = {}
d[:status:] = "active"

Methods

(eq) other

Symbols are compared by identity.

assert_eq :foo: :foo:
assert (:foo: != :bar:)

(lt) other

Symbols compare lexicographically by name.

assert (:alpha: < :beta:)