<div dir="ltr">Could someone move this to trunk? Just fixed the comment (since we don't have a NewDictionary in trunk currently).<div><br></div><div>I do have a mostly unrelated question. This method (newFrom:) checks to see if there is a duplicate key that in the source when making the new Dictionary, and fails if there is. But #newFromPairs: doesn't check - just happily writes over the previous value.</div><div><br></div><div>Dictionary newFromPairs: {'Red' . Color red . 'Blue' . Color blue . 'Green' . Color green. 'Blue' . Color green. }.<br></div><div><br></div><div>Is there a good, valid reason they are consistent?</div><div><br></div><div>-cbc</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 13, 2016 at 3:29 PM, <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A new version of Collections was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-cbc.689.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Collections-cbc.689.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-cbc.689<br>
Author: cbc<br>
Time: 13 April 2016, 3:28:58.221861 pm<br>
UUID: 84ae8fa7-91ee-4f47-8bdf-eadcac286a1e<br>
Ancestors: Collections-mt.688<br>
<br>
Fix comment in Dictioanry class>>newFrom: so that the examples actually work.<br>
<br>
=============== Diff against Collections-mt.688 ===============<br>
<br>
Item was changed:<br>
----- Method: Dictionary class>>newFrom: (in category 'instance creation') -----<br>
newFrom: aDict<br>
"Answer an instance of me containing the same associations as aDict.<br>
Error if any key appears twice."<br>
| newDictionary |<br>
newDictionary := self new: aDict size.<br>
aDict associationsDo:<br>
[:x |<br>
(newDictionary includesKey: x key)<br>
ifTrue: [self error: 'Duplicate key: ', x key printString]<br>
ifFalse: [newDictionary add: x copy]].<br>
^ newDictionary<br>
<br>
+ " Dictionary newFrom: {1->#a. 2->#b. 3->#c}<br>
+ {1->#a. 2->#b. 3->#c} as: Dictionary<br>
+ Dictionary newFrom: {1->#a. 2->#b. 1->#c}<br>
+ {1->#a. 2->#b. 1->#c} as: Dictionary<br>
- " NewDictionary newFrom: {1->#a. 2->#b. 3->#c}<br>
- {1->#a. 2->#b. 3->#c} as: NewDictionary<br>
- NewDictionary newFrom: {1->#a. 2->#b. 1->#c}<br>
- {1->#a. 2->#b. 1->#c} as: NewDictionary<br>
"!<br>
<br>
<br>
</blockquote></div><br></div>