aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-12-03 23:34:47 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-12-04 16:45:56 -0500
commit9b1a85747334e3e1c21e9a27f4aa79f7f44c1f2d (patch)
tree07868682f01264aad85710ee28fa19a9f711c37a /docs/markdown/snippets
parentb1c8f765fa6e2af0d185d2a20dc68c7567c916eb (diff)
downloadmeson-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/snippets')
-rw-r--r--docs/markdown/snippets/add_dictionary_variable_key.md20
1 files changed, 6 insertions, 14 deletions
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}
```