Project

General

Profile

Actions

Bug #12682

closed

Hash#flatten(level) does not recursively flatten inner hashes.

Added by krobi64 (Kristine Robison) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:76937]

Description

pry
[1] pry(main)> x = {a: {b: 1, c:2}}
=> {:a=>{:b=>1, :c=>2}}
[2] pry(main)> x.flatten(1)
=> [:a, {:b=>1, :c=>2}]
[3] pry(main)> x.flatten(2)
=> [:a, {:b=>1, :c=>2}]

Updated by marcandre (Marc-Andre Lafortune) over 7 years ago

  • Status changed from Open to Rejected

The documentation of Array#flatten is pretty clear:

"...That is, for every element that is an array, extract its elements into the new array."

So it follows the documentation and would create massive incompatibilities to change!

Actions

Also available in: Atom PDF

Like0
Like0