Strings
Interpolation
Section titled “Interpolation”{...} runs inside "..." and """...""" when { is followed by
identifier, digit, or (:
name := "Ada"println("Hello, {name}!")println("{1 + 2}") // 3
pi := 3.14159println("pi = {pi:.2f}") // 3.14n := 255println("hex = {n:x} HEX = {n:X} oct = {n:o} bin = {n:b} dec = {n:d}")A bare { that cannot expand warns at check time. Keep one interpolated
string per line for readable diffs.
Literal braces: double them
Section titled “Literal braces: double them”{{ renders {. A }} that closes a {{ renders }. Unmatched }}
stays literal, so JSON needs no escaping:
println("{{name}}") // {name}println("{{{name}}}") // {Ada}println("{\"a\": {}}") // {"a": {}}Prefer doubled braces over \{ / \} (kept for compatibility).
Raw strings: backticks
Section titled “Raw strings: backticks”Fully literal — no interpolation, no \ escapes, no brace collapsing:
j := json.parse(`{"a": 1}`)pat := `^[0-9a-f]{8}$`win := `C:\new\test`println(`a``b`) // a`b — doubled backtick is the only escapeTriple-backtick spans lines and dedents like """...""". A fence cannot
contain itself; split the string there.
Rule of thumb: brace-heavy payloads with no interpolation go in backticks;
literal braces inside interpolated strings use {{ / }}.
Multiline
Section titled “Multiline”css := """ .a{{color:red}} """Dedents to the least-indented line. Interpolation and doubling rules match "...".
Common ops (std.str)
Section titled “Common ops (std.str)”import std.str
" hi ".trim() // "hi""hello".to_upper() // "HELLO"str.contains("hello", "ell") // truestr.split("a,b,c", ",") // ["a", "b", "c"]str.replace("foo bar", "bar", "baz")Offsets (find, rfind, *_at, *_in, trim_span) are byte offsets, O(1) each.
length/slicing stay char-oriented — convert explicitly when mixing.
See Strings and arrays for the full table.