Although not alternative syntax, the below notations work as expected:
["A", "B", "C"] # 1; // B
["A", "B", "C"] #1; // B
["A", "B", "C"]#1; // B
["A", "B", ["C", "D"]]#2#0; // C
Selects an element from an Array, same as select command for arrays, but has higher precedence.
Note
# has higher precedence than all binary operators, but it has lower precedence than unary operators (see #Example 3).
array # index
Parameters:
Returns: Anything
[1, 2, 3, 4] # 2; // result is 3
getPosASL player # 2; // result is Z component of player's position
// 'getPosASL' is unary; '#' and '+' are binary; precedence is: 'getPosASL' > '#' > '+'
getPosASL player # 2 + 1; // equivalent to (getPosASL player # 2) + 1, not (getPosASL player)#(2+1)
select · selectRandom · selectRandomWeighted · set · resize · reverse · in · find · toArray · toString · forEach · count · deleteAt · deleteRange · append · sort · param · params · splitString · joinString · pushBack · pushBackUnique · apply
Although not alternative syntax, the below notations work as expected:
["A", "B", "C"] # 1; // B
["A", "B", "C"] #1; // B
["A", "B", "C"]#1; // B
["A", "B", ["C", "D"]]#2#0; // C
Here is an example of what higher precedence means:
[1, 2, 3, 4] select 2 / 2; // divides 2 with 2, therefore selects the second element at index 1, result = 2
[1, 2, 3, 4] select (2 / 2); // same result with brackets
[1, 2, 3, 4] # 2 / 2; // selects third element, then divides by 2 = 1.5
([1, 2, 3, 4] # 2) / 2; // same result with brackets
This operator can not be used in conjunction with the #define preprocessor.
#define SEL_ERR [0,1,2]#0; // error
#define SEL_NOERR [0,1,2] select 0; // works
Beware new-lines when using this operator. I suspect the preprocessor to fail. The following code will not compile without throwing an error:
[0]
# 0;