diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2019-12-03 23:34:47 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2019-12-04 16:45:56 -0500 |
commit | 9b1a85747334e3e1c21e9a27f4aa79f7f44c1f2d (patch) | |
tree | 07868682f01264aad85710ee28fa19a9f711c37a /docs/markdown | |
parent | b1c8f765fa6e2af0d185d2a20dc68c7567c916eb (diff) | |
download | meson-9b1a85747334e3e1c21e9a27f4aa79f7f44c1f2d.zip meson-9b1a85747334e3e1c21e9a27f4aa79f7f44c1f2d.tar.gz meson-9b1a85747334e3e1c21e9a27f4aa79f7f44c1f2d.tar.bz2 |
dict: Fully evaluate keys
The only restriction is keys must be string after evaluation. This fix
various inconsistencies.
Diffstat (limited to 'docs/markdown')
-rw-r--r-- | docs/markdown/Syntax.md | 12 | ||||
-rw-r--r-- | docs/markdown/snippets/add_dictionary_variable_key.md | 20 |
2 files changed, 16 insertions, 16 deletions
diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md index b96e6e1..cf0516c 100644 --- a/docs/markdown/Syntax.md +++ b/docs/markdown/Syntax.md @@ -324,8 +324,8 @@ Dictionaries -- Dictionaries are delimited by curly braces. A dictionary can contain an -arbitrary number of key value pairs. Keys are required to be literal -strings, values can be objects of any type. +arbitrary number of key value pairs. Keys are required to be strings, values can +be objects of any type. Prior to *0.53.0* keys were required to be literal strings. ```meson my_dict = {'foo': 42, 'bar': 'baz'} @@ -359,6 +359,14 @@ if 'foo' not in my_dict endif ``` +*Since 0.53.0* Keys can be any expression evaluating to a string value, not limited +to string literals any more. +```meson +d = {'a' + 'b' : 42} +k = 'cd' +d += {k : 43} +``` + Function calls -- diff --git a/docs/markdown/snippets/add_dictionary_variable_key.md b/docs/markdown/snippets/add_dictionary_variable_key.md index 373ce04..72294ae 100644 --- a/docs/markdown/snippets/add_dictionary_variable_key.md +++ b/docs/markdown/snippets/add_dictionary_variable_key.md @@ -1,17 +1,9 @@ -## Adding dictionary entry using string variable as key - -New dictionary entry can now be added using string variable as key, -in addition to using string literal as key. +## Dictionary entry using string variable as key +Keys can now be any expression evaluating to a string value, not limited +to string literals any more. ```meson -dict = {} - -# A variable to be used as a key -key = 'myKey' - -# Add new entry using the variable -dict += {key : 'myValue'} - -# Test that the stored value is correct -assert(dict[key] == 'myValue', 'Incorrect value retrieved from dictionary') +d = {'a' + 'b' : 42} +k = 'cd' +d += {k : 43} ``` |