AssociateTo[a,keyval]
changes the association a by adding the key-value pair keyval.
AssociateTo[a,{key1val1,key2val2,…}]
adds all key-value pairs keyivali.
AssociateTo
AssociateTo[a,keyval]
changes the association a by adding the key-value pair keyval.
AssociateTo[a,{key1val1,key2val2,…}]
adds all key-value pairs keyivali.
Details
- AssociateTo has attribute HoldFirst.
- AssociateTo effectively modifies the value of a in place.
Examples
Basic Examples (3)
assoc = Association[{a -> 1, b -> 2, c -> 3}]Change the value associated with a:
AssociateTo[assoc, a -> 11]If a key is not already in the association, it is added to it:
AssociateTo[assoc, d -> 4]Change several values in an association:
assoc = Association[{a -> 1, b -> 2, c -> 3}]AssociateTo[assoc, {b -> 22, c -> 33, d -> 44}]Append one association to another:
assoc = Association[{a -> 1, b -> 2}]assoc2 = Association[{c -> 3}]AssociateTo[assoc, assoc2]Related Guides
History
Text
Wolfram Research (2014), AssociateTo, Wolfram Language function, https://reference.wolfram.com/language/ref/AssociateTo.html.
CMS
Wolfram Language. 2014. "AssociateTo." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AssociateTo.html.
APA
Wolfram Language. (2014). AssociateTo. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AssociateTo.html
BibTeX
@misc{reference.wolfram_2026_associateto, author="Wolfram Research", title="{AssociateTo}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/AssociateTo.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_associateto, organization={Wolfram Research}, title={AssociateTo}, year={2014}, url={https://reference.wolfram.com/language/ref/AssociateTo.html}, note=[Accessed: 13-June-2026]}