Methods are called with a dot and they chain. Every signature below was checked
against the implementation rather than transcribed.
Method Result Notes
upper() / lower()String "auth".upper() → "AUTH"
len()Int counts characters: "héllo".len() → 5
trim()String strips surrounding whitespace
split(sep)List "a,b".split(",") → ["a", "b"]
replace(from, to)String every occurrence
starts_with(prefix) / ends_with(suffix)Bool
contains(substr)Bool "hello".contains("ell") → true
to_int() / to_float()Int / Float a malformed number is an error, not null
slice(start, end)String substring by character index, end exclusive, indices clamped
to_str()String identity, for use in chains
parse_json() / parse_yaml() / parse_toml()Object integers become Int; a failure is E0314
↳ fidelity key order is the document’s; YAML << is merged; a TOML datetime becomes a String
parse_duration()Int (seconds) "1h30m" → 5400; units d/h/m/s; E0319
parse_datetime()Int (epoch UTC) RFC 3339 or YYYY-MM-DD; offsets ±HH:MM; E0320
sha256()String lower-case hex digest
base64() / base64_decode()String standard alphabet with padding; invalid input is E0321
Method Result Notes
abs()Int
to_float()Float widening; there is no Float.to_int(), which would have to round
to_str()String
format_duration()String 5400 → "1h30m"; 0 → "0s"
format_datetime()String RFC 3339 UTC: 946684800 → "2000-01-01T00:00:00Z"
Method Result
abs()Float
round(digits)Float
to_str()String
Method Result
to_str()String
Method Result Notes
len()Int
first() / last()element an empty list is E0317
get(i) / get(i, default)element a miss gives null, or the default if you supply one
contains(item)Bool structural equality
compact()List drops null
uniq()List deduplicates, keeping first occurrences in order
map (x, i) -> ... endList the callback receives the element and its index
filter (x, i) -> Bool endList a non-Bool from the callback is E0306
join(sep)String scalars only; containers are E0307
sort()List
reverse()List
sum()Int
min() / max()element
flatten()List one level: [[1], [2, 3]] → [1, 2, 3]
to_object()Object builds an object from { key, value } pairs; a repeated key is E0323
reduce(init) (acc, e) -> … endAny left fold; the initial value is required
any (e, i) -> Bool endBool some element matches; false for an empty list
all (e, i) -> Bool endBool every element matches; true for an empty list
find(default) (e, i) -> Bool endAny first match, or the default
index_of(value, default)Int index of the first equal element, or the default; the default must be an Int
group_by (e, i) -> key endObject elements by a String key, keys in the order they first appear (D39)
sort_by (e, i) -> key endList ascending and stable; keys follow sort() (D39)
flat_map (e, i) -> [...] endList map, then the lists joined one level; a non-List from the lambda is E0306 (D39)
zip(other)List { left, right } pairs; lists of different lengths are E0327 (D39)
slice(start, end)List end exclusive: [1, 2, 3].slice(1, 3) → [2, 3]
to_json() / to_yaml() / to_toml()String the compact form, for embedding; to_toml on a list is E0603
to_json_pretty() / to_yaml_pretty() / to_toml_pretty()String the form a person reads, for a file that gets diffed
Method Result Notes
len()Int
keys() / values()List declaration order
contains(key)Bool
get(key, default)value a miss gives the default
entries()List { key, value } objects in declaration order; the inverse of to_object()
merge(other)Object the right side’s keys win
to_json() / to_yaml() / to_toml()String the compact form, for embedding
to_json_pretty() / to_yaml_pretty() / to_toml_pretty()String the form a person reads, for a file that gets diffed
Most operators are numeric. Two are not, and they are the only ones whose result
can be larger than what went in.
Expression Result Notes
"a" + "b"String joins two strings; interpolation "#{a}#{b}" does the same
[1] + [2, 3]List joins two lists; the operands are unchanged
+ never converts. "port " + 8080 is E0306, and the diagnostic names the
side to call .to_str() on. Joining is bounded at 1,000,000 list elements and
16 MiB of string, reported as E0322.
Function Right required Behaviour
range(n)— [0, 1, … n-1]
env(name, default)--allow-envan environment variable; absent → the default
read_file(path)--allow-readthe file’s contents as a string; a relative path is read from the manifest’s folder (D37)
fail(message)— stops with E0531 and your message
A method call takes precedence over an object field of the same name that happens
to hold a function. A package’s exported functions are called with the same
syntax: pkg.fn(...).