I have an array of hashes from which I need the values of the hashes in a new array. The array of hashes look likes this, with a couple thousand of them.
array =
arr =[{:code=>"404"}, {:code=>"302"}, {:code=>"200"}] arr.map { |h| h[:code] } #=> ["404", "302", "200"]
or, if the name of the key (now :code) might change in future:
:code
arr.map { |h| h.first.last } #=> ["404", "302", "200"]