Raise ArgumentError from method
def Fixnum.random(min, max)
raise ArgumentError, "min > max" if min > max
return min + rand(max-min+1)
end
Fixnum.random(10, 20) # => 13
Fixnum.random(-5, 0) # => -5
Fixnum.random(10, 10) # => 10
Fixnum.random(20, 10)
# ArgumentError: min > max
Related examples in the same category