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]
| Type | Methods | Page |
|---|---|---|
string | 41 | String Methods |
number | 43 | Number Methods |
bigint | 26 | Bigint Methods |
bool | 1 | Boolean Methods |
list | 40 | List Methods |
dict | 21 | Dictionary Methods |
range | 9 | Range Methods |
bytes | 25 | Bytes Methods |
file | 27 | File Methods |
function | 6 | Function 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.