[squeak-dev] The Inbox: Collections-cbc.689.mcz

Chris Cunningham cunningham.cb at gmail.com
Wed Apr 13 22:33:18 UTC 2016


Could someone move this to trunk? Just fixed the comment (since we don't
have a NewDictionary in trunk currently).

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.

Dictionary newFromPairs: {'Red' . Color red . 'Blue' . Color blue . 'Green'
. Color green. 'Blue' . Color green. }.

Is there a good, valid reason they are consistent?

-cbc


On Wed, Apr 13, 2016 at 3:29 PM, <commits at source.squeak.org> wrote:

> A new version of Collections was added to project The Inbox:
> http://source.squeak.org/inbox/Collections-cbc.689.mcz
>
> ==================== Summary ====================
>
> Name: Collections-cbc.689
> Author: cbc
> Time: 13 April 2016, 3:28:58.221861 pm
> UUID: 84ae8fa7-91ee-4f47-8bdf-eadcac286a1e
> Ancestors: Collections-mt.688
>
> Fix comment in Dictioanry class>>newFrom: so that the examples actually
> work.
>
> =============== Diff against Collections-mt.688 ===============
>
> 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]].
>         ^ newDictionary
>
> + "     Dictionary newFrom: {1->#a. 2->#b. 3->#c}
> +       {1->#a. 2->#b. 3->#c} as: Dictionary
> +       Dictionary newFrom: {1->#a. 2->#b. 1->#c}
> +       {1->#a. 2->#b. 1->#c} as: Dictionary
> - "     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
>   "!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160413/9fca6a5f/attachment.htm


More information about the Squeak-dev mailing list