From: Run Paint Run Run Date: 2009-08-05T00:43:27+09:00 Subject: [ruby-core:24745] [Bug #1880] Hash#flatten Doesn't Operate Recursively for Hash Values Bug #1880: Hash#flatten Doesn't Operate Recursively for Hash Values http://redmine.ruby-lang.org/issues/show/1880 Author: Run Paint Run Run Status: Open, Priority: Low Category: core ruby -v: ruby 1.9.2dev (2009-08-04 trunk 24388) [i686-linux] Hash#flatten claims to flatten recursively if given an argument specifying the depth. This works as expected for Array values, but has no bearing on Hash values. >> h = {orange: :orange, coconut: {inside: :white, outside: :brown}, grapes: {colour: [:red, :green]}} >> h.flatten => [:orange, :orange, :coconut, {:inside=>:white, :outside=>:brown}, :grapes, {:colour=>[:red, :green]}] >> h.flatten(20) => [:orange, :orange, :coconut, {:inside=>:white, :outside=>:brown}, :grapes, {:colour=>[:red, :green]}] This seems peculiar. If the user has specified a depth he's explicitly stating the level of recursion to flatten; not how he wants Array values to be treated. IOW, I expected #flatten(depth) to call #flatten on Hash values as appropriate. This can be generalised to: call #flatten on values until the depth has been reached. ---------------------------------------- http://redmine.ruby-lang.org