tags:

views:

44

answers:

2

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 the hash like {"sku_id"=>4, "brand_active"=>"true", "salesman_active"=>"true"}

+1  A: 
hash.each { |k,v| hash[k] = v[0] }
Manivannan j
+1  A: 
Hash[hash.map {|k, v| [k, *v] }]
Jörg W Mittag
+1 for functional programming
Wayne Conrad