From: dima Date: 2007-08-30T04:55:05+09:00 Subject: Re: How to make an array of hashes to a single array with all the values of these hashes ? On Aug 29, 8:45 pm, Phrogz wrote: > On Aug 29, 12:39 pm, kazaam wrote: > > > That's an array of hashes or? But how to get this to an array of the values of these hashes? > > Depending on what you want, try either: > my_array.map{ |h| h[:url] } > or > my_array.map{ |h| h.values }.flatten The beauty is that you can do the same stuff in so many different ways ;-) data = [{:url=>"http://www.ruby-lang.org/"}, {:url=>"http://www.ruby- lang.org/en/20020101.html"}, {:url=>"http://en.wikipedia.org/wiki/ Ruby_programming_language"}, {:url=>"http://en.wikipedia.org/wiki/ Ruby"}, {:url=>"http://www.rubyonrails.org/"}, {:url=>"http:// www.youtube.com/watch?v=JMDcOViViNY"}, {:url=>"http:// www.rubycentral.org/"}, {:url=>"http://www.zenspider.com/Languages/ Ruby/QuickRef.html"}, {:url=>"http://www.rubycentral.com/book/"}, {:url=>"http://poignantguide.net/"}] a = [] data.collect do |item| item.each_value { |value| a << value } end