Answers for "how to get max and min array ruby"

0

ruby find max value in array

# using .max for arrays
arr = [1,3,4,5]
arr.max
Posted by: Guest on January-04-2022
0

ruby get min value from array

people = {'joe' => 21, 'bill' => 35, 'sally' => 24}

people.min_by { |name, age| age } #=> ["joe", 21]
people.max_by { |name, age| age } #=> ["bill", 35]
Posted by: Guest on October-18-2020

Browse Popular Code Answers by Language