From cd30d1889f2bae34f17231b9cabe665edd57e7ba Mon Sep 17 00:00:00 2001 From: Bruce Merry Date: Thu, 24 Aug 2023 14:50:05 +0200 Subject: Document that dicts can be indexed with [] --- docs/markdown/Syntax.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'docs/markdown/Syntax.md') diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md index 9958db542..b69ad00ae 100644 --- a/docs/markdown/Syntax.md +++ b/docs/markdown/Syntax.md @@ -454,6 +454,15 @@ Keys must be unique: my_dict = {'foo': 42, 'foo': 43} ``` +Accessing elements of a dictionary works similarly to array indexing: + +```meson +my_dict = {'foo': 42, 'bar': 'baz'} +forty_two = my_dict['foo'] +# This will fail +my_dict['does_not_exist'] +``` + Dictionaries are immutable and do not have a guaranteed order. Dictionaries are available since 0.47.0. -- cgit v1.2.3