Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个红宝石数组
arr1 = [:a => {:name=>"Bob",:age=>"10",:city=>"NY"}, :b => {:name=>"Mike",:age=>"20",:city=>"FL"}]
将其转换为的最佳方法是什么
arr2 = [["Bob",10],["Mike",20]]
在红宝石中。
使用地图。
arr1.first.values.map{|h| [h[:name], h[:age].to_i]}