From: "David A. Black" Date: 2005-01-25T10:53:54+09:00 Subject: Re: Convert a Hash into an Array Hi -- On Tue, 25 Jan 2005, Michael Neumann wrote: > Eustaquio Rangel de Oliveira Jr. wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi! >> >> If I have: >> >> h = {"a"=>"111","b"=>"222"} >> h.to_a >> => [["a", "111"], ["b", "222"]] >> >> is there a method to convert a Hash into a "plain" Array like > > h.to_a.flatten will do the trick. However, if any of the hash values are arrays, they'll get flattened too: { "a" => [1,2,3] }.to_a.flatten # => ["a",1,2,3] unless of course you do: require 'flattenx' # from RAA { "a" => [1,2,3] }.to_a.flatten_by(1) # => ["a",[1,2,3]] :-) David -- David A. Black dblack@wobblini.net