Convert array of hashes to array

后端 未结 3 1954
一向
一向 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:44

    [{:code=>"404"}, {:code=>"302"}, {:code=>"200"}].flat_map(&:values)
    #⇒ ["404", "302", "200"]
    

提交回复
热议问题