A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ael.481.mcz==================== Summary ====================
Name: Collections-ael.481
Author: ael
Time: 30 July 2012, 2:40:08.671 pm
UUID: c2a7afc0-37ac-404b-ae81-bf782e1dd254
Ancestors: Collections-cwp.480
remove spurious sharing of associations between a dictionary and another created from it
=============== Diff against Collections-cwp.480 ===============
Item was changed:
----- Method: Dictionary class>>newFrom: (in category 'instance creation') -----
newFrom: aDict
"Answer an instance of me containing the same associations as aDict.
Error if any key appears twice."
| newDictionary |
newDictionary := self new: aDict size.
aDict associationsDo:
[:x |
(newDictionary includesKey: x key)
ifTrue: [self error: 'Duplicate key: ', x key printString]
+ ifFalse: [newDictionary add: x copy]].
- ifFalse: [newDictionary add: x]].
^ newDictionary
" NewDictionary newFrom: {1->#a. 2->#b. 3->#c}
{1->#a. 2->#b. 3->#c} as: NewDictionary
NewDictionary newFrom: {1->#a. 2->#b. 1->#c}
{1->#a. 2->#b. 1->#c} as: NewDictionary
"!