tbrent tbrent - 1 month ago 8
Ruby Question

Convert array of hashes to array

I have a array of hashes that i need the value side of the hashes in an array.
The array of hashes look like this with a couple thousand of them.

{:code=>"404"}, {:code=>"302"}, {:code=>"200"}


I have looked but can only find where it converts from a hash.
How would I go about doing this?

Answer
a=[{:code=>"404"}, {:code=>"302"}, {:code=>"200"}] 
puts a.map{|x|x.values}.flatten.inspect

output

["404", "302", "200"]