Project

General

Profile

Actions

Feature #18057

open

Introduce Array#mean

Added by ggmichaelgo (Michael Go) over 3 years ago. Updated 10 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:104740]

Description

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

array = [1, 2, 3]
array.mean # 2

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

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0