diff options
| author | franczc <fchin@biamp.com> | 2019-11-11 16:31:22 +1000 |
|---|---|---|
| committer | Michael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com> | 2019-11-12 09:21:10 -0500 |
| commit | adb4e071e688534fd7c163719f005239cd2f7c25 (patch) | |
| tree | e0c3a863adc14a28eb815d637ddd302d02ad9a97 /docs/markdown | |
| parent | 51d0e02292f571a0408c8a6a932b352fc6fd48e4 (diff) | |
| download | meson-adb4e071e688534fd7c163719f005239cd2f7c25.tar.gz | |
Adding dictionary entry using string variable as key.
Diffstat (limited to 'docs/markdown')
| -rw-r--r-- | docs/markdown/snippets/add_dictionary_variable_key.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/markdown/snippets/add_dictionary_variable_key.md b/docs/markdown/snippets/add_dictionary_variable_key.md new file mode 100644 index 000000000..373ce0476 --- /dev/null +++ b/docs/markdown/snippets/add_dictionary_variable_key.md @@ -0,0 +1,17 @@ +## 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. + +```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') +``` |
