Convert array of hashes to array

后端 未结 3 1992
一向
一向 2021-01-22 01:28

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 =         


        
3条回答
  •  无人共我
    2021-01-22 01:48

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

    output

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

提交回复
热议问题