---
name: "a hash b"
type: command
operator: "#"
status: ok
groups: ["Variables"]
arma3_since: "1.82"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/a_hash_b
revid: 377195
updated: 2026-01-01T10:56:03Z
---

# a hash b

*Command · Variables · Arma 3 v1.82*

## Description

Selects an element from an [Array](../topics/Array.md), same as [select](../commands/select.md) command for arrays, but has [higher precedence](../topics/Order_of_Precedence.md).

> [!NOTE]
> **#** has higher precedence than all binary operators, but it has lower precedence than unary operators (see [#Example 3](../commands/a_hash_b.md#example-3)).

## Syntax

```sqf
array # index
```

**Parameters:**

- `array`: [Array](../topics/Array.md) of [Anything](../topics/Anything.md)
- `index`: [Number](../topics/Number.md)

**Returns:** [Anything](../topics/Anything.md)

## Examples

### Example 1

```sqf
[1, 2, 3, 4] # 2;            // result is 3
```

### Example 2

```sqf
getPosASL player # 2;        // result is Z component of player's position
```

### Example 3

```sqf
// 'getPosASL' is unary; '#' and '+' are binary; precedence is: 'getPosASL' > '#' > '+'
getPosASL player # 2 + 1; // equivalent to (getPosASL player # 2) + 1, not (getPosASL player)#(2+1)
```

## See also

[select](../commands/select.md) · [selectRandom](../commands/selectRandom.md) · [selectRandomWeighted](../commands/selectRandomWeighted.md) · [set](../commands/set.md) · [resize](../commands/resize.md) · [reverse](../commands/reverse.md) · [in](../commands/in.md) · [find](../commands/find.md) · [toArray](../commands/toArray.md) · [toString](../commands/toString.md) · [forEach](../commands/forEach.md) · [count](../commands/count.md) · [deleteAt](../commands/deleteAt.md) · [deleteRange](../commands/deleteRange.md) · [append](../commands/append.md) · [sort](../commands/sort.md) · [param](../commands/param.md) · [params](../commands/params.md) · [splitString](../commands/splitString.md) · [joinString](../commands/joinString.md) · [pushBack](../commands/pushBack.md) · [pushBackUnique](../commands/pushBackUnique.md) · [apply](../commands/apply.md)

## Community notes

**KC Grimes** — 2018-04-25

Although not alternative syntax, the below notations work as expected:

```sqf
["A", "B", "C"] # 1;        // B
["A", "B", "C"] #1;            // B
["A", "B", "C"]#1;            // B
["A", "B", ["C", "D"]]#2#0;    // C
```

---

**7erra** — 2019-05-03

Here is an example of what higher precedence means:

```sqf
[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.

```sqf
#define SEL_ERR [0,1,2]#0;            // error
#define SEL_NOERR [0,1,2] select 0;    // works
```

---

**Fett_li** — 2021-04-02

Beware new-lines when using this operator. I suspect the preprocessor to fail. The following code will not compile without throwing an error:

```sqf
[0]
# 0;
```

<sub>Source: [BI Community Wiki — a hash b](https://community.bistudio.com/wiki/a_hash_b) (revision 377195).</sub>
