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

stan shepherd squeak414 at free.fr
Mon Jul 21 12:37:25 UTC 2008


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
-- 
View this message in context: http://www.nabble.com/How-to-shorten-a-method-%28using-inject%3A-into%3A--%29-tp18567292p18567292.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.



More information about the Beginners mailing list