[Newbies] i++

Michael Haupt mhaupt at gmail.com
Tue Mar 16 14:34:04 UTC 2010


Chris,

On Tue, Mar 16, 2010 at 3:12 PM, Chris Cunnington
<smalltalktelevision at gmail.com> wrote:
> But it seems to be blind spot in my Smalltalk knowledge. I keep trying:
>
> x := 0.
> (x < 10) whileTrue: [Transcript show: x.  x := x + 1]

with [x<10] instead of (x<10), this works perfectly for me, printing 0123456789.

> (1 to: 10) do: [: x | Transcript show: x.]

And this works out of the box.

(Squeak, trunk.)

> I don't see how to iterate the variable and then print it. It's as thought a
> value changed in a block wouldn't get fed back into that block.

I'm afraid I don't see the problem.

Best,

Michael


More information about the Beginners mailing list