Migration Guide : Migrating from Version 8.6.1 : Dictionary now implements #= and #hash
Dictionary now implements #= and #hash
Reason for change
A product use case surfaced that requires the ability to compare 2 dictionaries for equivalence. However, Dictionary inherited its implementation of #= and #hash from Object and these methods were identical to #== and #identityHash, thus testing for the 2 dictionaries being identical, not equivalent.
Change
Dictionary>>#= and Dictionary>>#hash have been added in CLDT. This implementation is inherited by all subclasses of Dictionary.
Action required
If your applications provide an implementation of Dictionary>>#= and/or Dictionary>>#hash, remove them after ensuring that they provided the same functionality as the new implementation.
In general, this change should not affect your application. However, if you have used a dictionary as a key in another dictionary, you will need to change this usage. The degenerate case is using a dictionary as a key in one of its own entries, like this:
| dictionary association |
dictionary := Dictionary new.
association := dictionary -> ‘bar’.
dictionary add: association.
Before this change you could retrieve the only entry in the dictionary using dictionary at: dictionary because the hash of a Dictionary did not change based on its content. After the change, dictionary at: dictionary will raise ExCLDTKeyNotFound because the hash of the key (dictionary) is based on the content of the dictionary, and therefore changed between when it was added to the dictionary and when it was retrieved. The workaround for this case is to use an IdentityDictionary rather than a Dictionary.
Last modified date: 04/05/2019