Tinderbox v10 Icon

dictionary(dictionaryStr)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Data Type Returned: 

Operator First Added: 

Operator in Current Baseline: 

Operator Last Altered: 

 Function  [other Function type actions]

 Document  [operators of similar scope]

 Dictionary, Set & List operations  [other Dictionary, Set & List operations operators]

 Dictionary [about Dictionary data type]

 v9.0.0

 Baseline

 As at baseline


dictionary(dictionaryStr)

This operator constructs a new dictionary from a dictionaryStr. The dictionaryStr must contain pairs of keys and values separated by a colon; each key/value pair is separated by a semicolon. For example:

$MyDictionary=dictionary("cat:animal; dog:animal; rock: mineral"); 

The key "cat" has the value "animal", while the key "rock" has the value "mineral".

Normally the output will be passed to a Dictionary attribute, but if passed to an action code variable the latter should function as if a dictionary.

The operator's input string will be in the form of semi-colon delimited set of key:value pairs, i.e.

$MyDictionary = dictionary("cat:animal; dog:animal; rock:mineral"); 

Or

$MyString = "cat:animal; dog:animal; rock:mineral"; 
$MyDictionary = dictionary($MyString); 

dictionary({dictionaryStr})

Using the newer {}-defined declaratory method for dictionary data:

$MyDictionary = dictionary({cat:animal; dog:animal; rock:mineral}); 

Or

$MyString = "cat:animal; dog:animal; rock:mineral"; 
$MyDictionary = dictionary({$MyString}); 

Here the braces (curly brackets) replace the need for quotes enclosing strings.

Direct creation from a string (deprecated)

It is possible that a dictionary can be made by passing an appropriately structured string to a Dictionary type attribute, thus:

$MyDictionary = "cat:animal; dog:animal; rock:mineral"; 

This latter usage is deprecated and the more explicit dictionary() operator should be used in its place.


See also—notes linking to here: