Skip to content

Data

Module name: "string". Called as methods on string values.

MethodSignatureDescription
len() -> intCharacter count
trim() -> stringStrip leading/trailing whitespace
trimStart() -> stringStrip leading whitespace
trimEnd() -> stringStrip trailing whitespace
toUpper() -> stringUppercase copy
toLower() -> stringLowercase copy
contains(sub: string) -> boolSubstring check
startsWith(prefix: string) -> boolPrefix check
endsWith(suffix: string) -> boolSuffix check
replace(from: string, to: string) -> stringReplace first occurrence
split(sep: string) -> Array<string>Split into parts
join(sep: string) -> stringJoin array with separator
charAt(index: int) -> stringCharacter at index
indexOf(sub: string) -> intIndex of substring
parse() -> anyParse to int or float
let s = " Hello, World! "
s.len() // 18
s.trim() // "Hello, World!"
s.toUpper() // " HELLO, WORLD! "
s.contains("World") // true
s.replace("World", "Writ") // " Hello, Writ! "
s.split(", ") // [" Hello", "World! "]
["a", "b", "c"].join(", ") // "a, b, c"
"42".parse() // 42 (int)
"3.14".parse() // 3.14 (float)

Module name: "array". Called as methods on Array<T> values.

MethodSignatureDescription
len() -> intElement count
isEmpty() -> boolTrue if empty
contains(value: T) -> boolElement check
indexOf(value: T) -> intIndex of element
push(value: T)Append to end
pop() -> TRemove and return last
insert(index: int, value: T)Insert at index
remove(index: int)Remove at index
first() -> Optional<T>First element
last() -> Optional<T>Last element
slice(start: int, end: int) -> Array<T>Subarray (exclusive end)
reverse()Reverse in place
sort()Sort in place
map(fn: (T) -> U) -> Array<U>Transform each element
filter(fn: (T) -> bool) -> Array<T>Keep matching elements
reduce(init: U, fn: (U, T) -> U) -> UFold into a single value
let items = ["sword", "shield", "potion"]
items.len() // 3
items.contains("sword") // true
items.indexOf("shield") // 1
items.push("dagger")
items.pop() // "dagger"
items.first() // Optional<T> — first element
items.slice(1, 3) // subarray from index 1 to 3 (exclusive)
// Higher order
items.map((x: string) => x.toUpper())
items.filter((x: string) => x.len() > 4)
items.reduce(0, (acc: int, x: string) => acc + x.len())

Module name: "dictionary". Called as methods on Dictionary<K, V> values.

MethodSignatureDescription
len() -> intEntry count
isEmpty() -> boolTrue if empty
has(key: K) -> boolKey check
keys() -> Array<K>All keys
values() -> Array<V>All values
remove(key: K)Remove by key
merge(other: Dictionary<K, V>) -> Dictionary<K, V>Returns new merged dict
let scores = {"alice": 100, "bob": 95}
scores.len() // 2
scores.has("alice") // true
scores.keys() // Array<string>
scores.values() // Array<int>
scores.remove("bob")
scores.merge(otherDict) // returns new merged dict