WolframLang: Association, Get Value
Get Key's Value by Key
asso[key]
-
return the value of a key.
Return
Missing["KeyAbsent", key]
if key missing.xx = Association[ "a" -> 3, "b" -> 2 ] xx["b"] === 2 xx["c"] === Missing["KeyAbsent", "c"]
Lookup[asso, key]
-
return the value of key.
If the key missing, return
Missing["KeyAbsent", key]
.xx = Association[ "a" -> 3, "b" -> 2 ] Lookup[xx, "b"] === 2 Lookup[xx, "c"] === Missing["KeyAbsent", "c"]
Lookup[asso, key, default]
-
use default if the key missing.
xx = Association[ "a" -> 3, "b" -> 2 ]; Lookup[xx, "c", 99] === 99
Lookup[asso, listOfKeys]
-
return a list of the values associated with the keys.
Lookup[listOfAssoc, key]
-
get a list of values of a key, from the list of associations.
Get Key's Value by Index
to get the value by index, just use Part
xx = Association[ "a" -> 3, "b" -> 2 ] xx[[1]] === 3