Strings
Strings are text values.
String Literals
Section titled “String Literals”Use single or double quotes for strings:
const name: string = "John"println(name)Concatenation
Section titled “Concatenation”Use + to concatenate strings:
const data = "Nubo"println(data + "!")Template Strings
Section titled “Template Strings”Use backticks for template strings with ${...} interpolation:
struct User { name: string}
impl User { fn sayHello(self: User) void { println(`Hi! I am ${self.name}!`) }}String Length
Section titled “String Length”Strings support length():
type hasLen: iface { length() int}
fn len(obj: hasLen) int { return obj.length()}
const name: string = "John"println(len(name))Use bytes() to work with the bytes of a string:
let x: int = 0
bytes("hello").map(int).each(fn(n: int) { x = x + n})
println(x)