[Newbies] i++

Chris Cunnington smalltalktelevision at gmail.com
Tue Mar 16 14:12:14 UTC 2010

I have a piece of code in an OpenGL book:

for(angle = 0.0f; angle <= GL_PI; angle += (GL_PI/20.0f))
     { //the expression}

It looks to me like something I see in JavaScript a lot:

i=0; i<10; i++

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]


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

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.

Any help would be appreciated.


More information about the Beginners mailing list