Arrays have a couple methods to get the minimum and maximum. Three common ones are .min, .max, .minmax. .max will get you the maximum value. [1,2,3].max #=> 3 ["a", "b", "c"].max #=> "c" .min will get the minimum value. [1,2,3].min #=> 1 ["a", "b", "c"].min #=> "a"
How to get the min and max from an Array (Ruby)
How to get the min and max from an Array…
How to get the min and max from an Array (Ruby)
Arrays have a couple methods to get the minimum and maximum. Three common ones are .min, .max, .minmax. .max will get you the maximum value. [1,2,3].max #=> 3 ["a", "b", "c"].max #=> "c" .min will get the minimum value. [1,2,3].min #=> 1 ["a", "b", "c"].min #=> "a"