Key

Key[key]

represents a key used to access a value in an association.

Key[key][assoc]

extracts the value corresponding to key in the association assoc.

Details

  • Key is used in functions such as Part to access values in Association objects.
  • Key can normally be omitted when key is a string.

Examples

Basic Examples  (4)

Extract a value from an association as a part:

Extract a value from an association by function application:

The Key wrapper is not necessary when the key is a string:

Lookups in associations interoperate with parts in lists and other expressions:

The explicit Key can be omitted when the keys in an association are strings:

Key is normally generated by functions such as Position:

Use Extract to extract the values:

Introduced in 2014
 (10.0)