# pushBack ## Category Array ## Arity **Binary** — ` pushBack `. ``` pushBack ``` ## Description Appends a single element to the end of the array. Returns the index at which the element was inserted (the new last index). This matches Arma SQF `pushBack` behavior. **Thread Safety**: Not thread-safe. Array must belong to current scheduler. ## How It Works Adds the element to the underlying `List`, then returns `Count - 1` (the index of the newly added element). The array grows by 1. ## Usage ### Basic push ```sqf _arr = [1, 2, 3]; _idx = _arr pushBack 4; // returns 3, _arr is [1,2,3,4] _arr pushBack 5; // _arr is [1,2,3,4,5] ``` ### Building arrays dynamically ```sqf _enemies = []; { if (_x get "side" == "east") then { _enemies pushBack _x; }; } forEach _allUnits; ``` ### Ignore return value ```sqf _queue pushBack _newTask; // just append, don't need index ``` ### Chain with return ```sqf _arr = []; _lastIdx = _arr pushBack "first"; // 0 _lastIdx = _arr pushBack "second"; // 1 ``` ## Thread Safety **Not thread-safe**. Array must be owned by the current scheduler. Use [freeze](freeze.md) for cross-scheduler sharing, or [sendTo](sendTo.md) to transfer ownership. ## See Also - [append](append.md) — append many elements at once - [deleteAt](deleteAt.md) — remove element - [select](select.md) — access element - [count](count.md) — array length - [resize](resize.md) — change array size