Prints debugging information about the provided arguments.
debug("Hello, World!") // Output: Hello, World!
Writes the provided arguments to the system standard output.
sysout "Hello, World!", "\n" // Output: Hello, World!
Prints the provided arguments without adding a new line.
print("Hello, World!") // Output: Hello, World!
Formats and prints the provided arguments according to the format specifier.
printf("Hello, %s!", "World") // Output: Hello, World!
Prints the provided arguments followed by a new line.
println("Hello, World!") // Output: Hello, World!
Reverses the provided array or string.
arr := [1, 2, 3]
revArr := reverse(arr) // revArr == [3, 2, 1]
str := "Hello"
revStr := reverse(str) // revStr == "olleH"
Checks if the array or string includes the provided element.
arr := [1, 2, 3]
hasTwo := includes(arr, 2) // hasTwo == true
str := "Hello"
hasE := includes(str, 'e') // hasE == false
Returns the index of the first occurrence of the provided element in the array or string.
arr := [1, 2, 3]
index := indexof(arr, 2) // index == 1
str := "Hello"
index := indexof(str, 'l') // index == 2
Returns the index of the last occurrence of the provided element in the array or string.
arr := [1, 2, 3, 2]
index := lastindexof(arr, 2) // index == 3
str := "Hello"
index := lastindexof(str, 'l') // index == 3
Returns the capacity of the array.
arr := [1, 2, 3]
capacity := cap(arr) // capacity == 3
Returns the number of elements if the given variable is array, string, map, or module map.
v := [1, 2, 3]
l := len(v) // l == 3
Creates a copy of the given variable. copy
function calls Object.Copy
interface method, which is expected to return a deep-copy of the value it holds.
v1 := [1, 2, 3]
v2 := v1
v3 := copy(v1)
v1[1] = 0
print(v2[1]) // "0"; 'v1' and 'v2' referencing the same array
print(v3[1]) // "2"; 'v3' not affected by 'v1'
Appends object(s) to an array (first argument) and returns a new array object. (Like Go's append
builtin.) Currently, this function takes array type only.
v := [1]
v = append(v, 2, 3) // v == [1, 2, 3]
Deletes the element with the specified key from the map type. First argument must be a map type and second argument must be a string type. (Like Go's delete
builtin except keys are always string). delete
returns null
value if successful and it mutates given map.
v := {key: "value"}
delete(v, "key") // v == {}
Deletes and/or changes the contents of a given array and returns deleted items as a new array. splice
is similar to JS Array.prototype.splice()
except splice is a builtin function and first argument must an array. First argument must be an array, and if second and third arguments are provided those must be integers otherwise runtime error is returned.
Usage:
deleted_items := splice(array[, start[, delete_count[, item1[, item2[, ...]]]])
v := [1, 2, 3]
items := splice(v, 0) // items == [1, 2, 3], v == []
Sorts the provided array.
arr := [3, 1, 2]
sortedArr := sort(arr) // sortedArr == [1, 2, 3]
Returns a new array of int with elements from start
to end
.
v := range(2, 5) // v == [2, 3, 4]
Returns a formatted string. The first argument must be a String object. See this for more details on formatting.
a := [1, 2, 3]
s := format("Foo: %v", a) // s == "Foo: [1, 2, 3]"
Returns the type name of an object.
typeof(1) // int
typeof("str") // string
typeof([1, 2, 3]) // array
Converts the provided rune to a integer.
r := rune('a') // r == 97
Tries to convert an object to string object. See Runtime Types for more details on type conversion.
x := string(123) // x == "123"
Tries to convert an object to int object. See this for more details on type conversion.
v := int("123") // v == 123
Optionally it can take the second argument, which will be returned if the first argument cannot be converted to int. Note that the second argument does not have to be int.
v = int(null, 10) // v == 10
v = int(null, false) // v == false
Tries to convert an object to bool object. See this for more details on type conversion.
v := bool(1) // v == true
Tries to convert an object to float object. See this for more details on type conversion.
v := float("19.84") // v == 19.84
Optionally it can take the second argument, which will be returned if the first argument cannot be converted to float. Note that the second argument does not have to be float.
v = float(null, 19.84) // v == 19.84
v = float(null, false) // v == false
Tries to convert an object to char object. See this for more details on type conversion.
v := char(89) // v == 'Y'
Optionally it can take the second argument, which will be returned if the first argument cannot be converted to float. Note that the second argument does not have to be float.
v = char(null, 'X') // v == 'X'
v = char(null, false) // v == false
Tries to convert an object to bytes object. See this for more details on type conversion.
v := bytes("foo") // v == [102 111 111]
If you pass an int to bytes()
function, it will create a new byte object with the given size.
v := bytes(100)
Tries to convert an object to time value.
v := time(1257894000) // 2009-11-10 23:00:00 +0000 UTC
Returns true
if the object's type is cycle. Or it returns false
.
Returns true
if the object's type is int. Or it returns false
.
Returns true
if the object's type is float. Or it returns false
.
Returns true
if the object's type is string. Or it returns false
.
Returns true
if the object's type is bool. Or it returns false
.
Returns true
if the object's type is char. Or it returns false
.
Returns true
if the object's type is bytes. Or it returns false
.
Returns true
if the object's type is array. Or it returns false
.
Returns true
if the object's type is immutable array. Or it returns false
.
Returns true
if the object's type is map. Or it returns false
.
immutable_map
Returns true
if the object's type is immutable map. Or it returns false
.
Returns true
if the object's type is time. Or it returns false
.
Returns true
if the object's type is function. Or it returns false
.
Returns true
if the object's type is null. Or it returns false
.
Returns true
if the object's type is error. Or it returns false
.
Returns true
if the object's type is iterable. Or it returns false
.