{"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","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.82"}],"since":{"game":"arma3","name":"Arma 3","version":"1.82"},"arma3_since":"1.82","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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","since":null,"effect":null,"exec":null,"params":[{"name":"array","type":"Array of Anything","optional":false,"default":null,"description":null,"types":["Array","Anything"],"since":null,"text":"array: Array of Anything"},{"name":"index","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"index: Number"}],"returns":{"type":"Anything","types":["Anything"],"description":null,"text":"Anything"},"form":"binary","operator":"#","left":{"text":"array","types":["Array","Anything"]},"right":{"text":"index","types":["Number"]}}],"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"]},{"text":"```sqf\n// 'getPosASL' is unary; '#' and '+' are binary; precedence is: 'getPosASL' > '#' > '+'\ngetPosASL player # 2 + 1; // equivalent to (getPosASL player # 2) + 1, not (getPosASL player)#(2+1)\n```","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)"]}],"multiplayer":null,"problems":null,"aliases":[],"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```"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Variables","Introduced with Arma 3 version 1.82","Scripting Commands"]}