My orginal hash is like as hash = {"sku_id"=>[4], "brand_active"=>["true"], "salesman_active"=>["true"]}
How to remove the array within hash. that means to convert th开发者_运维百科e hash like
{"sku_id"=>4, "brand_active"=>"true", "salesman_active"=>"true"}
hash.each { |k,v| hash[k] = v[0] }
Use this function:
Hash[hash.map {|k, v| [k, *v] }]
精彩评论