Quirrel4.41.0

types.Array.append

Method on every array
array.append(value, ...): any

Adds one or more values to the end of the array.

The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing ... from the prose below, not from the signature.

Parameters

valueanya value to add; give more than one to add several in one call
...any repeats

Return value

This array.

Errors

None of its own; append() with no value is a wrong-argument-count error from the VM, not from this function.

Notes

This binding is registered with a type mask that only covers the first argument, so the VM's signature shows one parameter, but append accepts any number of them: a.append(1, 2, 3) adds all three in one call and one resize, unlike array.push in some other Squirrel-family languages, which this build does not have.

Example

examples/types/array/append.nut
let a = [1, 2];
a.append(3);           // one value
a.append(4, 5, 6);      // append() takes any number of values in a single call
println("a =", ", ".join(a.map(@(v) v.tostring())));
println("a.append(7) == a:", a.append(7) == a);   // returns this array, not a copy
Output:
a = 1, 2, 3, 4, 5, 6
a.append(7) == a: true

See also

extendAppends every element of other to this array.
insertInserts value before the element currently at index, shifting the rest up by one.
arrayCreates an array of size elements, each set to default_value.
arrayclass index