Skip to content

Strings

Strings are sequences of characters.

Creating Strings

let simple = "Hello";
let with_quotes = "She said \"Hello\"";
let with_newline = "Line 1\nLine 2";

String Interpolation

let name = "Alice";
let age = 30;
let message = "My name is #{name} and I'm #{age}";
print message;

String Operations

let text = "Hello World";

// Concatenation
let greeting = "Hello" + " " + "World";

// Length
print len(text);  // 11

// Index
print text[0];   // H
print text[6];   // W

// Case conversion
print uppercase(text);  // HELLO WORLD
print lowercase(text);  // hello world

// Substring
print substr(text, 0, 5);  // Hello

// Split
let words = split(text, " ");
print words;  // ["Hello", "World"]

// Join
let joined = join(words, "-");
print joined;  // Hello-World