String interpolation
String literals support interpolation via ${...}. Any expression is
valid inside the braces.
let name = "Alice"let age = 30
let greeting = "Hello, ${name}!"let summary = "${name} is ${age} years old"let calc = "${a} * ${b} = ${a * b}"The embedded expression is evaluated and converted to a String via
the same stringification rules used by debug.
Any expression works
Section titled “Any expression works”"path = ${home.join("/")}" // method call"factorial(5) = ${factorial(5)}" // function call"${if x > 0 { "positive" } else { "negative" }}" // if-expression"${match status { Ok(v) => v.toString(), Error(_) => "err" }}" // matchIf the expression is itself a string, interpolation recurses naturally; no special handling is required.
Escapes
Section titled “Escapes”String literals support the usual escapes plus one for the interpolation metacharacter:
| Escape | Produces |
|---|---|
\" | double-quote |
\\ | backslash |
\n | newline |
\r | carriage return |
\t | tab |
\$ | literal $ |
let literal = "price is \$${price}" // price is $10Nesting and quoting
Section titled “Nesting and quoting”Double quotes inside an interpolated expression do not need escaping;
the interpolation delimiter is }, not ".
debug "name=${user.map(fn(u) { u.name }).unwrapOr("anonymous")}"Raw strings
Section titled “Raw strings”Raw string literals (without escape processing) are not currently supported. Use explicit escapes where needed.
Codegen
Section titled “Codegen”Interpolations desugar into string concatenation at compile time. The
generated Apex does not use String.format; it uses the + operator
with stringified operands, which matches Apex’s own preferred idiom.