DynamicBindings - how to get a snapshot

Stephen Pair stephen at pairhome.net
Fri Apr 25 19:37:14 UTC 2003


Derek Brans wrote:

> Here's what I came up with.
>  
> DynamicBindings>>snapshot
>  "returns an identity dictionary with a flattened view of me to be 
> saved for later"
>  |dictionary tmp|
>  dictionary _ IdentityDictionary new.
>  tmp _ self.
>  [tmp isNil not] whileTrue: [tmp keysAndValuesDo: [:k :v |
>    dictionary at: k ifAbsentPut: v]. tmp _ tmp parent].
>  ^ dictionary


Barring a couple minor typos, that'll work.  I would use #notNil instead 
of "tmp isNil not" just to be a bit more concise.

- Stephen



More information about the Squeak-dev mailing list