problem from a beginner

Vellinga, Mark vellinga at nwciowa.edu
Wed Feb 12 11:44:00 PST 2003


Hello,

I am trying to learn about squeak and writing a method to compute
factorial using a loop.  Here's my code

===========
fact
"an alternative to factorial method"

| answer end |

answer := 1.
end := self.

1 to: end do:
   [:index | answer := answer * index.

Transcript show: (answer printString), '  ', (index printString); cr. ]
============

The output looks fine, but when I call this method all that gets
returned is the original value sent.  Please help me clear this hurdle.

mv



More information about the Squeakland mailing list