WolframLang: Association, Get Value
Get Key's Value
assoc[key]
- return the value of a key.
Return
Missing["KeyAbsent", key]
if key no exist. Missing
Lookup[assoc, key]
- return the value of key.
If the key no exist, return
LookupMissing["KeyAbsent", key]
.xx = Association[ a -> 3, b -> 2 ]; Lookup[xx, b] === 2 Lookup[xx, c] === Missing["KeyAbsent", c]
Lookup[assoc, key, default]
- gives default if the key no exist.
xx = Association[ a -> 3, b -> 2 ]; Lookup[xx, c, 99] === 99
Lookup[assoc, {key1, key2 etc}]
- return a list of the values associated with the keys.
Lookup[{assoc1, assoc2 etc}, key]
- get a list of values of a key, from the list of associations .