[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] I get an output I wouldn't expect
From: |
ZuLuuuuuu |
Subject: |
[Help-smalltalk] I get an output I wouldn't expect |
Date: |
Mon, 13 Sep 2010 07:36:56 -0700 (PDT) |
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?
-----
Canol Gökel
--
View this message in context:
http://forum.world.st/I-get-an-output-I-wouldn-t-expect-tp2537546p2537546.html
Sent from the Gnu mailing list archive at Nabble.com.
- [Help-smalltalk] I get an output I wouldn't expect,
ZuLuuuuuu <=