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++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -