How to find the minimum value from the ranges in array of hashes in ruby? -


i have below array of hashes

z = {"range"=>[{"10-50"=>"5"}, {"50-100"=>"15"}, {"100-150"=>"25"}]}  

how can output 10

you can try following:

z["range"].map(&:keys).flatten.map(&:to_i).min #=> 10 

demo


Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - rosrun via ssh doesnt start a node properly -

Error C2280 mutex in a class C++ -