| 1 |
name: dict |
| 2 |
long_name: Dict |
| 3 |
since: 0.47.0 |
| 4 |
is_container: true |
| 5 |
description: | |
| 6 |
Stores a mapping of strings to other objects. See [dictionaries](Syntax.md#dictionaries). |
| 7 |
|
| 8 |
You can also iterate over dictionaries with the [`foreach` |
| 9 |
statement](Syntax.md#foreach-statements). |
| 10 |
|
| 11 |
*(since 0.48.0)*: Dictionaries can be added (e.g. `d1 = d2 + d3` and `d1 += d2`). |
| 12 |
Values from the second dictionary overrides values from the first. |
| 13 |
*(since 0.62.0)*: Dictionary order is guaranteed to be insertion order. |
| 14 |
|
| 15 |
|
| 16 |
methods: |
| 17 |
- name: has_key |
| 18 |
returns: bool |
| 19 |
description: Returns `true` if the dictionary contains the key given as argument, `false` otherwise. |
| 20 |
|
| 21 |
posargs: |
| 22 |
key: |
| 23 |
type: str |
| 24 |
description: The key to query. |
| 25 |
|
| 26 |
- name: get |
| 27 |
returns: any |
| 28 |
description: | |
| 29 |
returns the value for the key given as first |
| 30 |
argument if it is present in the dictionary, or the optional |
| 31 |
fallback value given as the second argument. If a single argument |
| 32 |
was given and the key was not found, causes a fatal error |
| 33 |
|
| 34 |
arg_flattening: false |
| 35 |
|
| 36 |
posargs: |
| 37 |
key: |
| 38 |
type: str |
| 39 |
description: The key to query. |
| 40 |
|
| 41 |
optargs: |
| 42 |
fallback: |
| 43 |
type: any |
| 44 |
description: Fallback value that is returned if the key is not in the [[@dict]]. |
| 45 |
|
| 46 |
- name: keys |
| 47 |
returns: list[str] |
| 48 |
description: Returns an array of keys in the dictionary. |