[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] Dictionary and Association
From: |
Gwenael Casaccio |
Subject: |
Re: [Help-smalltalk] Dictionary and Association |
Date: |
Wed, 06 Apr 2011 15:07:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 |
Hi,
you can simply do:
dict := Dictionary new.
dict at: #key1 put: 'value1'.
dict at: #key2 put: 'value2'.
In your case the problem is the assoc variable (you just change the
content) here is the solution:
dict := Dictionary new.
assoc := Association key: #key1 value: 'value1'. " or #key1->'value1' "
dict add: assoc.
assoc := Association key: #key2 value: 'value2'. " or #key2->'value2' "
dict add: assoc.
Gwen
On 04/06/2011 02:43 PM, Wolfgang Dann wrote:
Hi,
I don't understand what's wrong with this one:
st> dict := Dictionary new
Dictionary (
)
st> assoc := Association key: #key1 value: 'value1'
#key1->'value1'
st> dict add: assoc
#key1->'value1'
st> dict
Dictionary (
#key1->'value1'
)
st> assoc key: #key2 value: 'value2'
#key2->'value2'
st> dict
Dictionary (
#key2->'value2'
)
st> dict add: assoc
#key2->'value2'
st> dict
Dictionary (
#key2->'value2'
#key2->'value2'
)
best regards
_______________________________________________
help-smalltalk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-smalltalk