Files
mruby-mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
T
KOBAYASHI Shuji c5c39f585b Move Integral#(zero|nonzero|positive|negative)? to Numeric
Because these methods work if object is `Comparable`, and `Numeric` is
`Comparable`.
2019-05-17 21:13:31 +09:00

22 lines
199 B
Ruby

class Numeric
def zero?
self == 0
end
def nonzero?
if self == 0
nil
else
self
end
end
def positive?
self > 0
end
def negative?
self < 0
end
end