[#99868] [Ruby master Bug#17144] Tempfile.open { ... } does not unlink the file — eregontp@...
Issue #17144 has been reported by Eregon (Benoit Daloze).
15 messages
2020/09/03
[ruby-core:99928] [Ruby master Feature#17153] Add Enumerable#compact_map
From:
me@...
Date:
2020-09-04 23:28:23 UTC
List:
ruby-core #99928
Issue #17153 has been reported by jnchito (Junichi Ito).
----------------------------------------
Feature #17153: Add Enumerable#compact_map
https://bugs.ruby-lang.org/issues/17153
* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
----------------------------------------
I often write code like this (`map`, then `compact`):
``` ruby
nums = [1, 2, 3, 4, 5]
nums.map { |n| n * 10 if n.even? }.compact
#=> [20, 40]
```
Or like this:
``` ruby
nums.select(&:even?).map { |n| n * 10 }
#=> [20, 40]
```
I think it would be very useful and simpler if we could do it by calling one method:
``` ruby
nums.compact_map { |n| n * 10 if n.even? }
#=> [20, 40]
```
How about introducing `Enumerable#compact_map` ?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>