[Newbies] How to shorten a method (using inject: into: ?)

stan shepherd squeak414 at free.fr
Tue Jul 22 15:51:53 UTC 2008




Zulq Alam-2 wrote:
> 
> Using #inject:into and Point objects to store the totals:
> 
> testMaleMeiosis4
>    | totals |
>    totals := Forecaster testMale meiose inject: 0 at 0 into:
>      [:subtotals :strand |
>      subtotals + (strand maternalCount @ strand maternalCount)].
>    self should: [totals = 100 at 100]
> 
> The point notation makes it look very clean (to me).
> 

I agree it's very tidy looking.

Is there a style issue with introducing an object type which is not part of
the problem? Is point often used like this- it's being treated as a
shorthand form of an array of 2 elements which has some handy methods, is it
not?

...Stan
-- 
View this message in context: http://www.nabble.com/How-to-shorten-a-method-%28using-inject%3A-into%3A--%29-tp18567292p18592530.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.



More information about the Beginners mailing list