help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Dictionary usage question..


From: Rick Flower
Subject: Re: [Help-smalltalk] Dictionary usage question..
Date: Thu, 27 Sep 2012 07:10:22 -0700
User-agent: Apple Webmail/0.6

On 26.09.2012 23:44, Paolo Bonzini wrote:

The braces are the important part here. These are not string, they are
NodeTag objects (it is documented: try "XML.Attribute comment"). Thus
you need:

aCollection do: [:each | dict at: each name asString put: each value ].

to build the dictionary.

Paolo.. You are correct -- as usual!  I didn't see that forest for the
trees either.. Your code above worked great and got me past the sticky
part and the above "asString" can be changed to "type" and works fine
that way as well.. One thing if you don't mind.. Can you please clue me
in on why the version on the XML GST page won't work as claimed?  The
code is below and does use associations -- however, I thought I saw code to deal with associations in Dictionary's when I was perusing the source
yesterday -- perhaps not? :

^Dictionary withAll: (aCollection
        collect: [ :each | each key type -> each value ])

This results in the following Dictionary object for the earlier
data :

An instance of Dictionary
  tally: 2
  contents: [
    1->'label'->'use-case-Name-1'
    2->'link'->'http://foobar.com'
  ]

While I do have a functional workaround I'm just curious and would like
to update that part of the GST docs if the examples are incorrect..
Thanks again for saving my bacon!

--Rick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]