{"name":"a hash b","operator":"#","title":"a hash b","type":"command","url":"https://community.bistudio.com/wiki/a_hash_b","revid":377195,"updated":"2026-01-01T10:56:03Z","groups":["Variables"],"status":"ok","games":{"arma3":"1.82"},"since":"arma3 1.82","arma3_since":"1.82","description":"Selects an element from an Array, same as select command for arrays, but has higher precedence.\n\n> [!NOTE]\n> **#** has higher precedence than all binary operators, but it has lower precedence than unary operators (see Example 3).","syntaxes":[{"syntax":"array # index","params":[{"name":"array","type":"Array of Anything","type_expr":"Array<Anything>"},{"name":"index","type":"Number","type_expr":"Number"}],"returns":{"type":"Anything","type_expr":"Anything"},"form":"binary","left":{"text":"array"},"right":{"text":"index"}}],"examples":[{"text":"```sqf\n[1, 2, 3, 4] # 2;            // result is 3\n```","code":["[1, 2, 3, 4] # 2;\t\t\t// result is 3"]},{"text":"```sqf\ngetPosASL player # 2;        // result is Z component of player's position\n```","code":["getPosASL player # 2;\t\t// result is Z component of player's position"]},{"code":["// 'getPosASL' is unary; '#' and '+' are binary; precedence is: 'getPosASL' > '#' > '+'\ngetPosASL player # 2 + 1; // equivalent to (getPosASL player # 2) + 1, not (getPosASL player)#(2+1)"]}],"see_also":["select","selectRandom","selectRandomWeighted","set","resize","reverse","in","find","toArray","toString","forEach","count","deleteAt","deleteRange","append","sort","param","params","splitString","joinString","pushBack","pushBackUnique","apply"],"notes":[{"user":"KC Grimes","date":"2018-04-25T00:51:00Z","text":"Although not alternative syntax, the below notations work as expected:\n\n```sqf\n[\"A\", \"B\", \"C\"] # 1;        // B\n[\"A\", \"B\", \"C\"] #1;            // B\n[\"A\", \"B\", \"C\"]#1;            // B\n[\"A\", \"B\", [\"C\", \"D\"]]#2#0;    // C\n```"},{"user":"7erra","date":"2019-05-03T15:41:00Z","text":"Here is an example of what higher precedence means:\n\n```sqf\n[1, 2, 3, 4] select 2 / 2;        // divides 2 with 2, therefore selects the second element at index 1, result = 2\n[1, 2, 3, 4] select (2 / 2);    // same result with brackets\n[1, 2, 3, 4] # 2 / 2;            // selects third element, then divides by 2 = 1.5\n([1, 2, 3, 4] # 2) / 2;            // same result with brackets\n```\n\nThis operator can not be used in conjunction with the #define preprocessor.\n\n```sqf\n#define SEL_ERR [0,1,2]#0;            // error\n#define SEL_NOERR [0,1,2] select 0;    // works\n```"},{"user":"Fett_li","date":"2021-04-02T16:18:00Z","text":"Beware new-lines when using this operator. I suspect the preprocessor to fail. The following code will not compile without throwing an error:\n\n```sqf\n[0]\n# 0;\n```"}]}