Project

General

Profile

Feature #18057

Updated by ggmichaelgo (Michael Go) over 3 years ago

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

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

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

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

Back