Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

String Interpolation

Alpha (v0.1). Breaking changes expected.

Keel strings support {expr} interpolation — variables and expressions inside strings are evaluated at runtime.

Basic interpolation

name = "Keel"
notify user "Hello, {name}!"           # "Hello, Keel!"
notify user "Count: {items.count}"     # "Count: 3"
notify user "Sum: {a + b}"            # expression evaluation

Dotted paths

notify user "From: {email.from}"
notify user "Status: {self.count}"
notify user "Key: {env.API_KEY}"

Escape sequences

SequenceResult
\nNewline
\tTab
\rCarriage return
\\Backslash
\"Double quote
\{Literal { (prevents interpolation)
\}Literal }
notify user "Line 1\nLine 2"
notify user "Price: \{not interpolated\}"

String methods

MethodReturnsExample
.lengthint"hello".length5
.is_emptybool"".is_emptytrue
.contains(s)bool"hello".contains("ell")true
.starts_with(s)bool"hello".starts_with("hel")true
.ends_with(s)bool"hello".ends_with("lo")true
.trim()str" hi ".trim()"hi"
.upper()str"hello".upper()"HELLO"
.lower()str"HELLO".lower()"hello"
.split(sep)list[str]"a,b,c".split(",")["a","b","c"]
.replace(old, new)str"hello".replace("l","r")"herro"
.to_int()int?"42".to_int()42
.to_float()float?"3.14".to_float()3.14