From: Matthias Reitinger Date: 2009-07-22T09:35:07+09:00 Subject: Re: Mean method �lph� Bl�� wrote: > I adjusted the code a bit to handle the size factor with @size in > initialize (code changed if you refresh pastie). Unfortunately this produces wrong results when the array changes in between. Consider this: array = [1,2,3,4] mean = Mean.new(array) puts mean.arithmetic # => 2.5 array << 5 puts mean.arithmetic # => 3.75 puts Mean.new(array).arithmetic # => 3.0 As the size is only determined once in Mean#initialize, subsequent changes of the array (size) go unnoticed. This behaviour should at least be documented. -Matthias