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

xen::array

Provides utilities for working with arrays. All of the available functions in this namespace are also available as member functions to array objects.

include array;

Public Functions

len

len (arr: array) -> number

Returns the number of values in the array.

push

push (arr: array, value: any) -> number | null

Pushes a new value to the array. Returns the new number elements or null if failed.

pop

pop (arr: array) -> any

Pops the most recent value from the array and returns it. This removes the value from the array.

first

first (arr: array) -> any

Returns the first element in the array.

last

last (arr: array) -> any

Returns the last element in the array.

clear

clear (arr: array) -> null

Empties the given array, removing all previous values.

contains

contains (arr: array, value: any) -> bool | null

Returns whether the given value exists in the array.

index_of

index_of (arr: array, value: any) -> number | null

Gets the index of the given value in the array.

reverse

reverse (arr: array) -> array | null

Reverse the insertion order of the elements in the array.

join

join (arr: array, delim: string) -> string | null

Joins each element in the array with the given delimeter and returns a string.