Basic Examples (5)
Append a new value to an association at the top level:
Associate a new value to an existing key, noting that the order of the association is maintained:
Associate a new value to an existing key at the second level:
New keys may also be appended at nested levels:
Nested associations will be created at depth according to the given key specification:
Scope (1)
Arbitrary keys are supported:
Applications (2)
Starting with an association of contacts, append a new contact as an association at the top level:
Update an existing value deep in the nested association:
Properties and Relations (4)
When appending a new key/value pair, NestedAssociate is equivalent to Append, but with different key syntax:
NestedAssociate guarantees the order of keys is maintained, whereas Append does not:
Values can be retrieved from a nested association using resource function NestedLookup:
Keys can be dropped from a nested association using resource function NestedKeyDrop:
Possible Issues (4)
Where keys are themselves lists, they must be wrapped in Key:
Not wrapping a list-key in Key returns a Failure:
Where keys are themselves keys, they must be given in the form Key[Key[key]]:
NestedAssociate strips off the first Key in each key of the key sequence:
Some built-in functions support this syntax:
Others do not:
Avoid this issue by using only strings as keys, and not wrapping keys in Key:
Where RuleDelayed is used in the given association, NestedAssociate may cause undesired evaluation: