Functions
contains core
fn (s: Str, substring: Str): Bool
Return true if s contains substring.
Example
contains("hello world", "world") // true
contains("hello world", "xyz") // false
ends-with core
fn (s: Str, suffix: Str): Bool
Return true if s ends with suffix.
Example
ends-with("hello.txt", ".txt") // true
ends-with("hello.txt", ".md") // false
is-blank core
fn (s: Str | Null): Bool
Return true if s is null, empty, or contains only whitespace.
Example
is-blank(null) // true
is-blank("") // true
is-blank(" ") // true
is-blank(" \t\n ") // true
is-blank("hello") // false
is-empty core
fn (s: Str): Bool
Return true if string s is empty. Alias of ::hot::coll/is-empty.
Example
is-empty("") // true
is-empty("hello") // false
join core
fn (values: Vec, delim: Str): Str
Join values with delimiter delim.
Example
join(["a", "b", "c"], ",") // "a,b,c"
join(["hello", "world"], " ") // "hello world"
length core
fn (s: Str): Int
Get the length of string s. Alias of ::hot::coll/length.
Example
length("hello") // 5
length("") // 0
lowercase core
fn (s: Str): Str
Convert s to lowercase.
Example
lowercase("HELLO") // "hello"
lowercase("HeLLo") // "hello"
pad-end core
fn (s: Str, width: Int, pad: Str): Str
fn (s: Str, width: Int): Str
Pad s on the right to width using pad (default space).
Example
pad-end("hi", 5, ".") // "hi..."
pad-end("hi", 5) // "hi "
pad-end("hello", 3) // "hello" (unchanged)
pad-start core
fn (s: Str, width: Int, pad: Str): Str
fn (s: Str, width: Int): Str
Pad s on the left to width using pad (default space).
Example
pad-start("42", 5, "0") // "00042"
pad-start("hi", 5) // " hi"
pad-start("hello", 3) // "hello" (unchanged)
replace core
fn (s: Str, from: Str, to: Str): Str
Replace first occurrence of from with to in s.
Example
replace("hello world", "world", "Hot") // "hello Hot"
replace("aaa", "a", "b") // "baa" (first only)
See also: ::hot::regex/replace for pattern-based replacement.
slice core
fn (s: Str, start: Int, end: Int): Str
Get a slice of string s from start to end. Alias of ::hot::coll/slice.
Example
slice("hello world", 0, 5) // "hello"
slice("hello world", 6, 11) // "world"
split core
fn (s: Str, delim: Str): Vec
Split string s on delimiter delim.
Example
split("a,b,c", ",") // ["a", "b", "c"]
split("hello world", " ") // ["hello", "world"]
See also: ::hot::regex/split for pattern-based splitting.
starts-with core
fn (s: Str, prefix: Str): Bool
Return true if s starts with prefix.
Example
starts-with("hello world", "hello") // true
starts-with("hello world", "world") // false
trim core
fn (s: Str): Str
Trim whitespace from both ends of s.
Example
trim(" hello ") // "hello"
trim("\t\ntext\n") // "text"
trim-end core
fn (s: Str): Str
Trim whitespace from the end of s.
Example
trim-end(" hello ") // " hello"
trim-start core
fn (s: Str): Str
Trim whitespace from the start of s.
Example
trim-start(" hello ") // "hello "
uppercase core
fn (s: Str): Str
Convert s to uppercase.
Example
uppercase("hello") // "HELLO"
uppercase("HeLLo") // "HELLO"