looking for answers to exercises in Squeak book Ch 2.

Doug Way dway at riskmetrics.com
Thu Apr 26 20:44:08 UTC 2001


"Randal L. Schwartz" wrote:
> 
> You're gonna shoot me when you see how easy this is:
> 
>   anArray := #(12 14 16 18 20).
>   theAverage := (anArray sum) / (anArray size)
> 
> Learn to use the method finder.  Helps tremendously.

Yep.  In this case, you know the input is #(12 14 16 18 20) and the output will be 16, so you can enter this into the upper left pane of the Method Finder:

#(12 14 16 18 20). 16

This will reveal three methods that will yield that result:

#(12 14 16 18 20) average --> 16
#(12 14 16 18 20) median --> 16
#(12 14 16 18 20) third --> 16

Fun stuff!  Someone really needs to write up a beginner's tutorial for the Method Finder.

- Doug Way
  dway at riskmetrics.com





More information about the Squeak-dev mailing list