[ruby-core:94366] [Ruby master Feature#16104] Introduce merge_if and merge_if!
From:
janfri26@...
Date:
2019-08-15 06:54:02 UTC
List:
ruby-core #94366
Issue #16104 has been updated by janfri (Jan Friedrich).
akash (Akash Gupta) wrote:
> The method `merge_if` / `merge_if!` will merge the passed hash in parameter only if the block evaluates to true, otherwise not. Similar to `count` method with a block.
What if the callee has more than one entry? For example
```ruby
a = {a: 'Apple', c: 'Pear'}
a.merge_if(b: 'Ball') {|k, v| v == 'Apple'}
# => ???
```
The block is called twice and evaluates one time `true` and the other `false`.
----------------------------------------
Feature #16104: Introduce merge_if and merge_if!
https://bugs.ruby-lang.org/issues/16104#change-80777
* Author: akash (Akash Gupta)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
The method `merge_if` / `merge_if` will merge the passed hash in parameter only if the block evaluates to true, otherwise not. Similar to `count` method with a block.
--
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>