[ruby-core:104753] [Ruby master Feature#18057] Introduce Array#mean
From:
ggmichaelgo@...
Date:
2021-08-02 14:16:14 UTC
List:
ruby-core #104753
Issue #18057 has been updated by ggmichaelgo (Michael Go).
@nobu - yup, you are correct. The expected behaviour should be like this
```ruby
[1,2].mean #=> 1.5
```
----------------------------------------
Feature #18057: Introduce Array#mean
https://bugs.ruby-lang.org/issues/18057#change-93089
* Author: ggmichaelgo (Michael Go)
* Status: Open
* Priority: Normal
----------------------------------------
Introduce Array#average to calculate the average value of an array.
```ruby
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
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>