On 09/13/2010 04:36 PM, ZuLuuuuuu wrote:
Hello,
The output of the code below:
a := OrderedCollection new.
1 to: 3 do: [:number |
a add: [number printString printNl].
].
(a at: 1) value.
(a at: 2) value.
(a at: 3) value.
is:
'4'
'4'
'4'
I would expect it to be:
'1'
'2'
'3'
I modified the code like this:
a := OrderedCollection new.
1 to: 3 do: [:number |
| tempNumber |
tempNumber := number.
a add: [tempNumber printString printNl].
].
(a at: 1) value.
(a at: 2) value.
(a at: 3) value.
And I now get my expected value.
What is the logic here? Is there a more elegant way that you would suggest
to get the expected output?
It's a known bug. Mind reporting it at smalltalk.gnu.org?
Your workaround is the right way to fix it.
Paolo
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk