{"name":"append","title":"append","type":"command","url":"https://community.bistudio.com/wiki/append","revid":377193,"updated":"2026-01-01T10:54:49Z","groups":["Arrays"],"status":"ok","games":{"arma3":"1.40"},"since":"arma3 1.40","arma3_since":"1.40","description":"Appends array2 to the back of array1 modifying array1. See insert for an \"appendUnique\" equivalent.\n\n> [!NOTE]\n> append does not return array, it modifies the existing array. If you need to return a copy, use \"+\":\n>\n> ```sqf\n> array3 = array1 + array2;\n> ```","syntaxes":[{"syntax":"array1 append array2","params":[{"name":"array1","type":"Array of Anything","type_expr":"Array<Anything>"},{"name":"array2","type":"Array of Anything","type_expr":"Array<Anything>"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"array1"},"right":{"text":"array2"}}],"examples":[{"code":["_arr = [1,2,3];\n_arr append [4,5,6];\nhint str _arr; // [1,2,3,4,5,6]"]}],"see_also":["set","pushBack","pushBackUnique","insert","+","apply","select","resize","reverse","count","deleteAt","deleteRange"],"notes":[{"user":"Heeeere's Johnny!","date":"2015-03-09T00:41:00Z","text":"```sqf\n_array1 append _array2;\n```\n\nis roughly 1.2× faster (depending on array size) than\n\n```sqf\n_array1 = _array1 + _array2\n```\n\n(Averaged over 10.000 iterations with two identical arrays containing the numbers 0 through 9)\n\nThe larger the arrays to append, the faster append is as it does not create a new array, which happens with array addition."},{"user":"Killzone_Kid","date":"2015-05-21T10:27:00Z","text":"Array \"unshift\" implementation using append, a faster alternative to BIS_fnc_arrayUnShift:\n\n```sqf\nKK_fnc_unshift = {\n    private [\"_arr\", \"_tmp\"];\n    _arr = _this select 0;\n    _tmp = [_this select 1];\n    _tmp append _arr;\n    _arr resize 0;\n    _arr append _tmp;\n    _arr\n};\n\n// Example\narr = [1,2,3];\n[arr, 0] call KK_fnc_unshift; // both arr and return of function are [0,1,2,3]\n```"},{"user":"Killzone_Kid","date":"2015-05-21T15:21:00Z","text":"Array \"insert\" implementation using append, much faster alternative to BIS_fnc_arrayInsert:\n\n```sqf\nKK_fnc_insert = {\n    private [\"_arr\", \"_i\", \"_res\"];\n    _arr = _this select 0;\n    _i = _this select 2;\n    _res = [];\n    _res append (_arr select [0, _i]);\n    _res append (_this select 1);\n    _res append (_arr select [_i, count _arr - _i]);\n    _res;\n};\n\n// Example\narr = [1,2,3,4];\n[arr, [\"a\",\"b\"], 2] call KK_fnc_insert; // [1,2,\"a\",\"b\",3,4]\n```"},{"user":"Killzone_Kid","date":"2015-05-21T15:52:00Z","text":"A faster alternative to BIS_fnc_arrayPushStack using append:\n\n```sqf\nKK_fnc_pushStack = {\n    _this select 0 append (_this select 1);\n    _this select 0\n};\n\n// Example\narr = [1,2,3];\n[arr, [4,5,6]] call KK_fnc_pushStack; // both arr and function return are [1,2,3,4,5,6]\n```"}]}