Get values from hash in ruby -
i have hash looks this:
{"0"=>{"car_addition_id"=>"9"}, "1"=>{"car_addition_id"=>"10"}} i want hash "10" , "9" values in array. how can that? in advance!
try out:
h = {"0"=>{"car_addition_id"=>"9"}, "1"=>{"car_addition_id"=>"10"}} h.map{|k,v| v.values}.flatten => ["9", "10"] or per @gotva
h.flat_map{|k,v| v.values} ruby hash
No comments:
Post a Comment