- If you need to store information that is useful throughout your
application, then you can store that information in the Smalltalk
dictionary. Keyvalue pairs stored in the Smalltalk dictionary are
often called global-variableglobal-variable-value pairs.
- If you want to create and assign a global variable, then instantiate
the following pattern:
Smalltalk at: #global-variable name put: value
- If you want to access the value of a global variable, then use the
global variable's name.
- If you want to reassign a global variable, then instantiate one of the
following patterns:
Smalltalk at: #global-variable name put: new value
global-variable name := new value
- If you want to create a new dictionary that is assigned to a global
variable, then instantiate the following pattern:
Smalltalk at: #dictionary name put: Dictionary new
- If you want to add a new keyvalue entry to a dictionary, then
instantiate the following pattern:
dictionary name at: 'key name' put: initial value
- If you want to know the value of a keyvalue entry in a dictionary,
then instantiate the following pattern:
dictionary name at: 'key name'
- If you need to store information that is needed in several parts of
your application, then you should store that information in a
dictionary, and then you should include that dictionary in the pool
dictionaries of the classes for which methods are defined that need
access to the dictionary.
- If you have installed a dictionary as a pool dictionary in a class,
then you can set and get the values stored in that dictionary using
assignment expressions to set values and keys to get values.