problem from a beginner

Bob Arning arning
Fri Apr 18 14:54:47 PDT 2003


Mark,

The one thing you are missing is to explicitly return the answer at the end of the method. Put

	^answer

as the last line in the method.

Cheers,
Bob

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
>
>===========
>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.




More information about the Squeakland mailing list