Strings
Calibre uses str for text.
String literals are written with double quotes.
let greeting : str = "Hello";let message := "Welcome to Calibre";You can join strings and other values with & (most primitive types would act as you expect).
let user := "Ada";let age := 32;
print("Hello " & user);print("Age: " & age);Strings come with useful standard library methods.
let text := "a,b,c";
print(text.split(","));print(text.replace("b", "B"));print(text.starts_with("a"));If you need to work with characters directly, you can convert a string into a list of chars.
let chars : list:<char> = "hello".to_chars();
// String Iters are iter:<char> not iter:<str> so this code is perfectly validlet chars : list:<char> = "hello".into_iter().collect();Calibre also supports template-style function calls for building strings.
const custom_fmt := fn (splits : list:<str>, inputs : list:<str>) -> str => { let mut txt : str = "";
for i in len(splits) => { txt &= splits[i]; if i < len(inputs) => txt &= inputs[i]; };
txt;}
const main := fn => { let mut formatted := "Hello, my name is {"Ada"} and I am {32}"; print(formatted);
// A similar fmt method is included as part of the stdlib formatted := fmt"Hello, my name is {"Ada"} and I am {32}"; print(formatted);}You will use strings often for input, output, file paths, parsing, and user-facing messages.