On 11 Mar 2013, at 22:40, "jannik.laval" <
[hidden email]> wrote:
> Hi all,
>
> There is something that I do not understand in Dictionary.
> I am not sure this is what we want.
>
> The following code:
> ===
> Dictionary new addAll:
> {#a -> #b.
> #c -> #d }; yourself
> ===
> returns "a Dictionary(1->#a->#b 2->#c->#d )"
>
> where I would like to have "a Dictionary(#a->#b #c->#d )".
>
> Ok, I do
> ===
> {#a -> #b.
> #c -> #d } asDictionary
> ===
> and it works.
>
> Jannik
Cool, I never saw that, the #asDictionary, very handy. I often use #newFromPairs:
You can also write:
Dictionary newFrom: { #foo->1. #bar->2 }.
For some reason, Dictionary>>#add: takes an association as argument, while Dictionary>>#addAll: takes a keyed collection.
Sven
--
Sven Van Caekenberghe
http://stfx.euSmalltalk is the Red Pill