mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
c5c39f585b
Because these methods work if object is `Comparable`, and `Numeric` is `Comparable`.
22 lines
199 B
Ruby
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
|