Last updated at 9:44 pm UTC on 18 February 2018
Dictionary is a subclass of Set.
A #Dictionary is a type of collection populated with entries which consists of an #Association, also known as a key/value pair. Both the key and the value can be any arbitrary object. Dictionaries are relatively fast at finding the value associated with a key. They are real work horses in Smalltalk programming. There are similar data structures like the hashes in Java and Perl.
The associations in a dictionary can be accessed by key or value. There are methods which will return a key, a value, or an association. Associations can be created in several different ways. The method -> dash right-arrow is an example of a non-alphabetic method name.
a:= Dictionary new.
a add:(Association key: 'Thomas' value: '55565325').
a at: 'Christoph' put: 4784582.
a add: 'Sample' -> ((Morph new)name: 'Sample').
a inspectWithLabel: '1st Dictionary'.
(a at: 'Sample') openInHand.
Transcript show: (a at: 'Christoph'); cr.
Transcript show: (a keyAtValue: '55565325').
JsonObject is a subclass of Dictionary.