Where’s Math.min and Math.max in Ruby?
Maybe it’s just me and I don’t know where to look, but this isn’t something I’m interested in spending 30 minutes looking for.
module Math
def self.max(a, b)
a > b ? a : b
end
def self.min(a, b)
a < b ? a : b
end
end
One comments so far...
You can use [a, b].max or [a, b].min.
This answer is from: http://stackoverflow.com/questions/1359370/how-do-you-find-a-min-max-with-ruby
Leave a Reply