aboutsummaryrefslogtreecommitdiff
path: root/docs/yaml/elementary/dict.yml
blob: f3ca837d0217bf5984a3159d751eaf61ecba3b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: dict
long_name: Dict
since: 0.47.0
is_container: true
description: |
  Stores a mapping of strings to other objects. See [dictionaries](Syntax.md#dictionaries).

  You can also iterate over dictionaries with the [`foreach`
  statement](Syntax.md#foreach-statements).

  *(since 0.48.0)* Dictionaries can be added (e.g. `d1 = d2 + d3` and `d1 += d2`).
  Values from the second dictionary overrides values from the first.


methods:
- name: has_key
  returns: bool
  description: Returns `true` if the dictionary contains the key given as argument, `false` otherwise.

  posargs:
    key:
      type: str
      description: The key to query.

- name: get
  returns: any
  description: |
    returns the value for the key given as first
    argument if it is present in the dictionary, or the optional
    fallback value given as the second argument. If a single argument
    was given and the key was not found, causes a fatal error

  arg_flattening: false

  posargs:
    key:
      type: str
      description: The key to query.

  optargs:
    fallback:
      type: any
      description: Fallback value that is returned if the key is not in the [[@dict]].

- name: keys
  returns: list[str]
  description: Returns an array of keys in the dictionary.