Project

General

Profile

Actions

Feature #16252

open

Hash#partition should return hashes

Added by Dan0042 (Daniel DeLorme) over 4 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:95336]

Description

Hash#partition is implemented by Enumerable so it just returns two arrays of arrays

{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

{1=>2,3=>4}.partition{|k,|k==1} #=> [{1=>2}, {3=>4}]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0