# select ## Category Array / String ## Arity **Binary** — ` select `. ``` select select ``` ## Description Returns the element at the given zero-based index from an array, or the character at the given index from a string. **Out-of-range index returns `nil`** (no error thrown — matches Arma SQF behavior). ## How It Works - **Array**: bounds-checks the index. Returns `array[index]`. O(1). - **String**: bounds-checks the index. Returns single-character string via `string[index].ToString()`. O(1). - **Out of range**: returns `nil` silently (no exception). ## Usage ### Array element access ```sqf _arr = ["a", "b", "c"]; _first = _arr select 0; // "a" _second = _arr select 1; // "b" _last = _arr select (count _arr - 1); // "c" _oob = _arr select 99; // nil (out of range) ``` ### String character access ```sqf _name = "Arma"; _char0 = _name select 0; // "A" _char2 = _name select 2; // "m" ``` ### Safe access with nil guard ```sqf _val = _arr select _index; if (!isNil "_val") then { process(_val); }; ``` ### In loop ```sqf for "_i" from 0 to (count _arr - 1) do { _elem = _arr select _i; systemChat f"Element {_i}: {_elem}"; }; ``` ## Thread Safety ReadOnly — pure query. Safe from any scheduler. ## See Also - [count](count.md) — array/string length - [find](find.md) — search for element - [in](in.md) — membership check - [set](set.md) — modify element at index - [deleteAt](deleteAt.md) — remove element at index