Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix E: Built-in Type Methods

Every method on every built-in type, with its signature, what it returns, and its edge cases. This is the reference; the chapters in Text, Numbers and Collections are the introduction.

Methods are called with a dot, on the value itself:

echo 'zuri'.upper()
echo 255.hex()
echo [3, 1, 2].sort()
ZURI
ff
[1, 2, 3]
TypeMethodsPage
string41String Methods
number43Number Methods
bigint26Bigint Methods
bool1Boolean Methods
list40List Methods
dict21Dictionary Methods
range9Range Methods
bytes25Bytes Methods
file27File Methods
function6Function Methods

What Is Not Listed Here

@key and @value exist on every iterable built-in type, which is what makes for ... in work on them. They are documented as a protocol in Appendix C rather than repeated on every page.

to_string() exists on every value, nil included.

Class instances carry whatever their class declares, plus to_string(). See Classes and Objects.

Module members are not methods. See Appendix F.

Conventions in These Pages

A parameter written name: ?type is optional. A parameter written ...name is variadic. A parameter with no type shown takes any value.

A method that mutates its receiver says so. Where a type has both, the distinction matters: list.sort() mutates and returns the list, while list.reverse() returns a new list and leaves the original alone.