aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets/dict_builtin.md
blob: 1bd24cef9822f9b21c78e292167fc891bc0d7bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
## New built-in object dictionary

Meson dictionaries use a syntax similar to python's dictionaries,
but have a narrower scope: they are immutable, keys can only
be string literals, and initializing a dictionary with duplicate
keys causes a fatal error.

Example usage:

```meson
dict = {'foo': 42, 'bar': 'baz'}

foo = dict.get('foo')
foobar = dict.get('foobar', 'fallback-value')

foreach key, value : dict
  Do something with key and value
endforeach
```