Skip to the page
Programs and the world / Built-in methods

Start here01

The language02

Programs and the world03

Kiln04

03 Programs and the world / 05

Built-in methods

Every method there is on built-in values. If it isn't here, it doesn't exist.

Numbers, Strings, arrays and hashes come with a small set of methods, and this page lists all of them, grouped by the type they belong to. Find the type, then the method: each table says what a call gives. A few rules hold across every table:

Marked changes
The method changes the value it's called on, so it can only be called on a var.
Is it empty?
There is no method for that. Write items.length == 0, which says exactly what is checked.
Methods with blocks
each, map, filter, find, any and all are on their own page: Blocks.
Enum values
Enum values have no methods.

Int and Float

An Int has one method:

MethodGives
n.abs()the value without its sign
n.quotient(d)how many whole times d goes into n, rounded down (see arithmetic)

A Float can also be rounded, to a whole number or to a number of decimals (see Rounding):

MethodGives
x.abs()the value without its sign
x.floor(), x.ceil(), x.round()an Int
x.floor(d), x.ceil(d), x.round(d)a Float with d decimals

String

None of a String's methods change it: each gives a new value. Lengths and positions are counted in characters, and positions start at 0.

Length, case and spaces

MethodGives
text.lengththe number of characters
text.upcase(), text.downcase()the text in upper or lower case
text.trim()the text without spaces, tabs or line breaks at either end
MethodGives
text.contains("x")true if "x" appears in the text
text.contains("x", at: Placement.start)true if the text starts with "x"; Placement.finish, if it ends with it
text.index_of("x")where "x" first starts, counted in characters, or nil

Cutting and changing

MethodGives
text.split(",")an array of the pieces between each ",", keeping empty pieces
text.slice(from: 3)the characters from the 4th on (they're counted from 0)
text.slice(from: 0, to: 2)the characters from the 1st up to, not with, the 3rd
text.replace("x", by: "y")the text with every "x" made "y"
text.charactersan array of the characters, each a String

slice counts characters, as length does, so "blåbær".slice(from: 2, to: 4) is "åb". Either end may be from 0 to the length. Outside that, or with to before from, it's an error that says which.

replace with "" to look for is an error, since "" is between every two characters.

slice-and-replace.hem
const line = "## Install"

print(line.slice(from: 3))        # prints Install
print(line.slice(from: 0, to: 2)) # prints ##
print(line.replace("#", by: "-")) # prints -- Install
print(line.index_of("I"))         # prints 3
print("blåbær".characters)        # prints ["b", "l", "å", "b", "æ", "r"]
print("abc".slice(from: 4))       # error: can't slice from 4: the text has 3 characters

For trimming, splitting and searching there are trim, split and contains, and join, a method of arrays, puts the pieces back together into one String:

trim-split-contains.hem
print("  Hi  ".trim() + "|")                        # prints Hi|
print("a,b,,c".split(","))                          # prints ["a", "b", "", "c"]
print("hello".contains("ell"))                      # prints true
print("hello".contains("he", at: Placement.start))  # prints true
print("hello".contains("lo", at: Placement.finish)) # prints true
print(["Ada", "Grace"].join(", "))                  # prints Ada, Grace
print([1, 2].join(", "))                            # error: join needs an array of Strings, got a [Int]; convert the items first with map and String(...)

Bytes

MethodGives
bytes.lengththe number of bytes
bytes[i]the byte at i, counted from 0, as an Int
bytes.contains(other)true if other appears in them
bytes.contains(other, at: Placement.start)true if they start with other; Placement.finish, if they end with it
bytes.slice(from: 3)the bytes from the 4th on
bytes.slice(from: 0, to: 2)the bytes from the 1st up to, not with, the 3rd
bytes.text()the text they hold, a String! (kind not_text if it isn't UTF-8)

Array

MethodGives
items.lengththe number of elements
items.contains(x)true if an element equals x
items.join(", ")one String; the array must be a [String]
items.push(x)changes adds x at the end
items.first()the first element, or nil
items.unique()a new array with each value once: the first of each, in order
items.limit(n), items.skip(n)a new array of the first n elements; of all but the first n
items.each, map, filter, find, any, allsee Blocks
items.sort, sum, min, max, average, tallysee Blocks: sorting and figures
items.groupsee Blocks: groups

Hash

MethodGives
ages.lengththe number of keys
ages.get(key)the value, or nil
ages.get(key, fallback: other)the value, or other
ages.has(key)true if the key exists
ages.keys, ages.valuesarrays, in order
ages.set(key, to: value)changes adds or replaces
ages.remove(key)changes removes the key if present
ages.eachsee Blocks

Time

MethodGives
time.plus(days: d, ...), time.minus(...)a later, or earlier, Time (see Time)
later.since(earlier)a Duration
time.in(zone)a LocalTime (see Zones)

Zone

MethodGives
zone.namea String: Europe/Copenhagen
zone.parse(text)a Time!, the moment the zone's clocks show that time

LocalTime

MethodGives
local.yearan Int; and so month, day, hour, minute, second and millisecond
local.weekdaya Weekday
local.datea String, the day: 2026-11-24
local.offseta Duration, how far from UTC
local.time, local.zoneits Time and its Zone

Duration

MethodGives
duration.dayshow long, in whole days, rounded toward zero; and so hours, minutes, seconds and milliseconds

Random

MethodGives
random.int(below: n)changes a number from 0 up to, not with, n
random.float()changes a Float from 0.0 up to, not with, 1.0
random.pick(items)changes one of the array's items