problem from a beginner
arning at charm.net
Wed Feb 12 13:26:09 PST 2003
The one thing you are missing is to explicitly return the answer at the end of the method. Put
as the last line in the method.
On Wed, 12 Feb 2003 11:44:00 -0600 "Vellinga, Mark" <vellinga at nwciowa.edu> wrote:
>I am trying to learn about squeak and writing a method to compute
>factorial using a loop. Here's my code
>"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.
More information about the Squeakland