---
name: "getOrDefaultCall"
type: command
status: ok
groups: ["HashMap"]
arma3_since: "2.12"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/getOrDefaultCall
revid: 378259
updated: 2026-03-26T00:21:49Z
---

# getOrDefaultCall

*Command · HashMap · Arma 3 v2.12*

## Description

Retrieves a value from the [HashMap](../topics/HashMap.md) for the given 'key', executes given 'code' if key was not found and returns result.
Additionally sets key to the code result value if *set* is true.

## Syntax

```sqf
hashMap getOrDefaultCall [key, code, set]
```

**Parameters:**

- `hashMap`: [HashMap](../topics/HashMap.md)
- `key`: [HashMapKey](../topics/HashMapKey.md) - case-sensitive key
- `code`: [Code](../topics/Code.md) - (Optional, default [nil](../commands/nil.md)) code to execute if the key does not exist
- `set`: [Boolean](../topics/Boolean.md) - (Optional, default [false](../commands/false.md)) if [true](../commands/true.md) and value does not exist in the provided hash map, the result of the *code* execution is added to the hash map

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

## Examples

### Example 1

```sqf
_hashmap getOrDefaultCall [123, { systemChat "The key 123 does not exist and will be created and assigned 345"; 345 }, true];
```

## See also

[getOrDefault](../commands/getOrDefault.md) · [HashMap](../topics/HashMap.md) · [get](../commands/get.md)

<sub>Source: [BI Community Wiki — getOrDefaultCall](https://community.bistudio.com/wiki/getOrDefaultCall) (revision 378259).</sub>
