diff options
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r-- | docs/markdown/snippets/add_dictionary_variable_key.md | 20 |
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} ``` |