This version is out of date, covering development from v9.0.0 to v9.3.0. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

Dictionary.add(key, value)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 Item   [operators of similar scope]

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

 9.1.0

 


Dictionary.add(key, value)

This sets a key to the value.

If key does not exist, that key is created with a value of value.

If key exists, key is given value value. This replaces any/all existing values for this key.

Assume $MyDictionary has no 'apple' key. Example:

$MyDictionary = $MyDictionary.add("apple","fruit"); 

The key 'apple' is added and now has value 'fruit'

$MyDictionary = $MyDictionary.add("apple","green"); 

The key 'apple' now has a new value 'green'. Now assume the 'apple' key has multiple values of 'fruit;green;red':

$MyDictionary = $MyDictionary.add("apple","pie"); 

Now the value is just 'pie' because a .add() operator replaces all existing value(s). To add an additional value(s) to existing value(s), see Dictionary.extend().

This operator is also equivalent to:

Dictionary["key"] = "value";