a := OrderedCollection new. (Smalltalk globals instVarNamed: 'declarations') keysAndValuesDo: [:key :value | a add: value].
b := OrderedCollection new. Smalltalk allClassesAndTraitsDo: [:v | b add: value]. b
Note that value should be scoped only to the first block. That second block should _not_ be able to see value. But it can, so (a) the code compiles and (b) produces #(nil nil nil ...).
frank
It doesn't see it. Doing the second part only will result in two bindings being created: "b" and "value". "value" is never initialized to anything so it is nil. If you do only the first part, just one binding is created: "a".
Cheers, Bob
On 11/2/13 6:42 AM, Frank Shearar wrote:
a := OrderedCollection new. (Smalltalk globals instVarNamed: 'declarations') keysAndValuesDo: [:key :value | a add: value].
b := OrderedCollection new. Smalltalk allClassesAndTraitsDo: [:v | b add: value]. b
Note that value should be scoped only to the first block. That second block should _not_ be able to see value. But it can, so (a) the code compiles and (b) produces #(nil nil nil ...).
frank
I realised this belatedly. It's a _different_ variable called 'value'.
And given that I make quite heavy use of Workspace's lack of declaring variables, I can't really complain.
Sorry for the noise.
frank
On 2 November 2013 13:57, Bob Arning arning315@comcast.net wrote:
It doesn't see it. Doing the second part only will result in two bindings being created: "b" and "value". "value" is never initialized to anything so it is nil. If you do only the first part, just one binding is created: "a".
Cheers, Bob
On 11/2/13 6:42 AM, Frank Shearar wrote:
a := OrderedCollection new. (Smalltalk globals instVarNamed: 'declarations') keysAndValuesDo: [:key :value | a add: value].
b := OrderedCollection new. Smalltalk allClassesAndTraitsDo: [:v | b add: value]. b
Note that value should be scoped only to the first block. That second block should _not_ be able to see value. But it can, so (a) the code compiles and (b) produces #(nil nil nil ...).
frank
squeak-dev@lists.squeakfoundation.org