Project

General

Profile

Feature #18057

Updated by ggmichaelgo (Michael Go) 3 months ago

Introduce Array#average to calculate the average value of an array. 

 ```ruby 
 array = [1, 2, 3] 
 array.mean array.average # 2 

 array = [1.5, 2.2, 3.1] 
 array.mean(&:round) array.average(&:round) # 2.3333333333333335 2 

 array = [-3, -2, -1] 
 array.mean array.average { |e| e.abs } # 2 
 ```

Back