Arma 3 Scripting

append

  • Arma 3 v1.40

Command · Markdown · JSON · original wiki page

Description

Appends array2 to the back of array1 modifying array1. See insert for an "appendUnique" equivalent.

Note

append does not return array, it modifies the existing array. If you need to return a copy, use "+":

array3 = array1 + array2;

Syntax

array1 append array2

Parameters:

Returns: Nothing

Examples

Example 1

_arr = [1,2,3];
_arr append [4,5,6];
hint str _arr; // [1,2,3,4,5,6]

See also

set · pushBack · pushBackUnique · insert · + · apply · select · resize · reverse · count · deleteAt · deleteRange

Community notes

Heeeere's Johnny!

_array1 append _array2;

is roughly 1.2× faster (depending on array size) than

_array1 = _array1 + _array2

(Averaged over 10.000 iterations with two identical arrays containing the numbers 0 through 9)

The larger the arrays to append, the faster append is as it does not create a new array, which happens with array addition.

Killzone_Kid

Array "unshift" implementation using append, a faster alternative to BIS_fnc_arrayUnShift:

KK_fnc_unshift = {
    private ["_arr", "_tmp"];
    _arr = _this select 0;
    _tmp = [_this select 1];
    _tmp append _arr;
    _arr resize 0;
    _arr append _tmp;
    _arr
};

// Example
arr = [1,2,3];
[arr, 0] call KK_fnc_unshift; // both arr and return of function are [0,1,2,3]