Quirrel4.53.0

array

Methods on every array.

Functions

appendarray.append(value, ...): anyAdds one or more values to the end of the array.
applyarray.apply(callback: function): anyReplaces every element with the result of callback on it.
clearclear(): anyRemoves every element from the array.
clonenodiscard clone(): anyMakes a shallow copy of the array.
constructorconstructor(size: number, [default_value], ...): anyCreates an array of size elements, each set to default_value.
containsnodiscard array.contains(value): anyReports whether any element equals value.
eacharray.each(callback: function): anyCalls callback once per element, in order.
extendarray.extend(other: array, ...): anyAppends every element of other to this array.
filternodiscard array.filter(callback: function): anyCollects the elements for which callback returns a true value.
findindexpure array.findindex(callback: function): anyFinds the index of the first element for which callback returns a true value.
findvaluepure array.findvalue(predicate: function, [default_value], ...): anyFinds the first element for which predicate returns a true value.
hasindexpure array.hasindex(index: number): anyReports whether index is a valid element index.
hasvaluepure array.hasvalue(value): anyReports whether any element equals value.
indexofpure array.indexof(value): anyFinds the index of the first element that equals value.
insertarray.insert(index: number, value): anyInserts value before the element currently at index, shifting the rest up by one.
is_frozennodiscard is_frozen(): anyReports whether this array reference is frozen.
lenpure array.len(): anyReturns the number of elements in the array.
mapnodiscard array.map(callback: function): anyBuilds a new array from the results of callback on each element.
poparray.pop(): anyRemoves and returns the last element.
reducenodiscard array.reduce(callback: function, [initial], ...): anyFolds the array down to one value by repeatedly combining an accumulator with each element.
removearray.remove(index: number): anyRemoves the element at index, shifting the rest down by one.
replacearray.replace(other: array): anyDeprecated alias of replace_with.
replace_witharray.replace_with(other: array): anyOverwrites this array's elements with other's.
resizearray.resize(size: number, ...): anyGrows or shrinks the array to size elements.
reversearray.reverse(): anyReverses the array in place.
slicenodiscard array.slice([start: number, end: number], ...): anyCopies the elements from start up to, but not including, end.
sortarray.sort([comparator: function], ...): anySorts the array in place.
sort_reversedarray.sort_reversed([comparator: function], ...): anySorts the array in place in descending order: the order of sort with the two arguments of each compare swapped.
sortbyarray.sortby(key: function): anySorts the array in place by the value that key returns for each element.
sortby_reversedarray.sortby_reversed(key: function): anySorts the array in place by the value that key returns for each element, in descending order.
swaparray.swap(index1: number, index2: number): anySwaps the elements at index1 and index2.
topnodiscard array.top(): anyReturns the last element without removing it.
tostringnodiscard tostring(): anyReturns the default text representation of this array.
totablepure array.totable(): anyBuilds a table from the array's elements.
weakrefnodiscard weakref(): anyReturns a weak reference to this array.