[squeak-dev] Dictionary>>addAll:

Levente Uzonyi leves at elte.hu
Tue Aug 24 09:50:33 UTC 2010


On Mon, 23 Aug 2010, Andreas Raab wrote:

> Hm ... tell me what you *think* this code would do:
>
>  dict := Dictionary withAll: {'foo' -> 'bar'. 'hello' -> 'world'}.
>
> then run it. Does that seem right to you?

Yes and no. :) Dictionary >> #addAll: expects a "KeyedCollection" as 
argument. Array is a "KeyedCollection" with integer keys.
But one could expect that #addAll: works like #add: which is not the case.
We could change #addAll: to use #associationsDo: instead of 
#keysAndValueesDo: as Nicolas said, but it might break some code.
If you just want to build a Dictionary from an Array of Associations, then 
#newFrom: does what you need (it uses the #associationsDo: trick).


Levente

>
> Cheers,
>  - Andreas
>
>



More information about the Squeak-dev mailing list