[Newbies] Re: How to shorten a method (using inject: into: ?)
Zulq Alam
me at zulq.net
Mon Jul 21 14:35:55 UTC 2008
Hi Stan,
How about using #detectSum:?
testMaleMeiosis2
pTotal := Forecaster testMale meiose
detectSum: [:strand | strand testRun paternalCount].
mTotal := Forecaster testMale meiose
detectSum: [:strand | strand testRun maternalCount].
self should: [mTotal = 100 and: [pTotal = 100]]
Other methods of this variety include #detectMin:, #detectMax: and
#count: and possibly others.
Regards,
Zulq.
stan shepherd wrote:
> Hi, I have the following method, that code critics flags as long:
>
> testMaleMeiosis2
> | testSet mCount pCount mTotal pTotal |
> pTotal := 0.
> mTotal := 0.
> Forecaster testMale meiose
> do: [:strand |
> testSet := strand testRun.
> mCount := testSet maternalCount.
> pCount := testSet paternalCount.
> mTotal := mTotal + mCount.
> pTotal := pTotal + pCount].
> self
> should: [mTotal = 100
> and: [pTotal = 100]]
>
> I'm trying to shorten it, including various attempts with inject: into: ,
> but with no success. Any tips please?
>
> ....Stan
More information about the Beginners
mailing list