DynamicBindings - how to get a snapshot
stephen at pairhome.net
Fri Apr 25 19:37:14 UTC 2003
Derek Brans wrote:
> Here's what I came up with.
> "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.
More information about the Squeak-dev