[#102652] [Ruby master Bug#17664] Behavior of sockets changed in Ruby 3.0 to non-blocking — ciconia@...
Issue #17664 has been reported by ciconia (Sharon Rosner).
23 messages
2021/02/28
[ruby-core:102393] [Ruby master Feature#17608] Compact and sum in one step
From:
sawadatsuyoshi@...
Date:
2021-02-04 06:18:40 UTC
List:
ruby-core #102393
Issue #17608 has been reported by sawa (Tsuyoshi Sawada).
----------------------------------------
Feature #17608: Compact and sum in one step
https://bugs.ruby-lang.org/issues/17608
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
----------------------------------------
Many use cases of `Array#sum` are preceded with the `compact` method or a block to ensure the value is addable.
```ruby
a = [1, nil, 2, 3]
a.sum # !> TypeError
a.compact.sum # => 6
a.sum{_1 || 0} # => 6
```
I propose there should be a way to do that in one step. I request either of the following:
A. `array#filter_sum` method
```ruby
a.filter_sum # => 6
```
B. An option for `Array#sum`
```ruby
a.sum(compact: true) # => 6
```
--
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>