[ruby-core:95336] [Ruby master Feature#16252] Hash#partition should return hashes
From:
daniel@...42.com
Date:
2019-10-15 15:12:47 UTC
List:
ruby-core #95336
Issue #16252 has been reported by Dan0042 (Daniel DeLorme).
----------------------------------------
Feature #16252: Hash#partition should return hashes
https://bugs.ruby-lang.org/issues/16252
* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Hash#partition is implemented by Enumerable so it just returns two arrays of arrays
```ruby
{1=>2,3=>4}.partition{|k,|k==1} #=> [[[1, 2]], [[3, 4]]]
```
But I think it would make more sense to behave similarly to Hash#select and Hash#reject
```ruby
{1=>2,3=>4}.partition{|k,|k==1} #=> [{1=>2}, {3=>4}]
```
--
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>