Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

How to find the key of the largest value hash?

# short version
hash.key(hash.values.max)

# longer more flexable version: 
puts hash.max_by(&:last).first

#without the .first you get the key and the value pair as array
 
PREVIOUS NEXT
Tagged: #How #find #key #largest
ADD COMMENT
Topic
Name
8+8 =