Tinderbox v9 Icon

Curly brackets: dictionaries and nested dictionaries

The newer { } notation allow Dictionary data type objects to be defined, or to define dictionary-type data as an item in a list. This is similar to the newer to the [ ] method for defining List or Set types, or nested list values,Thus:

$MyDictionary = {dog:terrier;boat:yawl;fruit:apple};

which replaces the older (still working) syntax:

$MyDictionary = dictionary("dog:terrier;boat:yawl;fruit:apple");

Just as a list can be used as a dictionary key value (see), a { } object can be used as a list item or a key value:

MyDictionary = {boat:yawl;plant:{fruit:apple;veg:pea};dog:terrier}; 

$MyValue = $MyDictionary[plant][veg]; gives 'pear'

Here a list is nested in a dictionary:

MyDictionary = {boat:yawl;fruit:[apple;pear];dog:terrier}; 

$MyValue = $MyDictionary[fruit][1]; gives 'pear'

Caution is advised in nesting deeply. So far only a single level of nesting has been well tested. Deeper nesting might result in unexpected outcomes.

Note that Dictionary keys have no notion of a sort order so a [N] numbered address must not be used in place of a [keyname] named address.