For the complete documentation index, see llms.txt. This page is also available as Markdown.

Utility

General-purpose methods available on every value.

.clone()same type

Returns an independent deep copy. Assigning with = shares a reference; .clone() does not, so mutating the copy never affects the original.

a = [1, 2, 3]
b = a.clone()
void b.append(4)
log a  // [1, 2, 3] - unchanged

.item(key)unknown

Reads an element or field dynamically: by 1-based index for arrays/strings, by key for objects. Handy when the key is computed.

arr = [10, 20, 30]
log arr.item(2)      // 20
o = { a: 7 }
log o.item("a")      // 7

.reverse()same type

Reverses a string or array.

log "abc".reverse()      // "cba"
log [1, 2, 3].reverse()  // [3, 2, 1]

.call(...args)unknown

Invokes a value that holds a function, passing args.

.match(pattern)array

Returns the matches of a string against pattern. See also the regex package.

Type assertions (advanced)

These perform a runtime downcast - they do not parse or convert. The value must already be exactly the named type or the program errors.

.assert(type)type

Asserts the value is type and returns it as that type; errors at runtime if it is not.

.assertElse(type, default)type

Like .assert, but returns default instead of erroring on a type mismatch.

These are strict about the underlying type: an integer literal is int, not number, so (123).assert("number") errors. Prefer .toNum() / .toInt() when you want conversion rather than a checked cast.

Last updated