Skip to content

Strings

String is UTF-8 text. Use double quotes for literals, <> to join text, and #{...} to interpolate strings, numbers, booleans, or atoms.

mod strings
pub fn greet(name: String) -> String {
"hello, #{name}"
}
pub fn join(left: String, right: String) -> String {
left <> right
}
pub fn label(count: Integer) -> String {
"count: #{count}"
}

Strings support escapes such as \n for a newline and \" for a quote.

Binary holds arbitrary bytes. Every String is a Binary, but raw bytes must be validated before use as text. See Errors for an example. Interpolating a raw Binary is a type error:

pub fn splice(bytes: Binary) -> String {
"#{bytes}"
}