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: Wed, 26 Sep 2012 18:39:57 -0700
User-agent: Apple Webmail/0.6

Ok.. I changed the way the dictionary was created and
it's now being done as follows to eliminate the association,
just to simplify.  If it matters I'm using version 3.2 of GST..

dictionaryForAttributes: aCollection [
        | dict |
        dict := Dictionary new.
        aCollection do: [:each | dict at: each key put: each value ].
        ^dict.
"  ^Dictionary withAll: (aCollection
                collect: [ :each | each key type -> each value ])"
]

Here's the code that populates it from an array of XML.Attributes:
        attributes := self dictionaryForAttributes: (each attributes).

Here's the results of what's now in the attributes dictionary :
        attributes inspect.

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

Here's the code that is trying to do a lookup for an item in the
dictionary..

        labelName := attributes at: 'label'.

And here's the results..

Object: Dictionary new: 32 "<-0x53bb440>" error: Invalid argument label: key not found
SystemExceptions.NotFound(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.NotFound(Exception)>>signal: (ExcHandling.st:264)
SystemExceptions.NotFound class>>signalOn:what: (SysExcept.st:758)
[] in Dictionary>>at: (Dictionary.st:139)
Dictionary>>at:ifAbsent: (Dictionary.st:149)
Dictionary>>at: (Dictionary.st:138)

I just don't get it.. I must be missing something here..

--Rick



reply via email to

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