Browsing in Pharo, I found that Dictionary has a subclass KeyedTree, which is 
in effect a set of nested dictionaries. Retrieval is by quoting a path, which 
is simply an array of keys. So in your case it would read:

dict1 atPath: #(’key1’ ‘key2’ ‘key3’). 

This might be more efficient than repeated use of the DNU mechanism. It is not 
clear (to me, at least) how to construct the nested dictionaries as a KeyedTree 
in the first place, but this might be an alternative approach.

 

Hope this helps

 

Peter Kenny

 

From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
Markus Böhm
Sent: 24 April 2017 18:42
To: pharo-users@lists.pharo.org
Subject: [Pharo-users] Hot to retrieve values from Nested Dictionaries

 

May I ask:

What's the idiomatic way to retrieve values from nested dictionaries?

 

(((dict1 at: 'key1') at: 'key2') at: 'key3')

 

Are all the brackets really necessary?

 

BR Mike

Reply via email to