1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Faster multiple_of? method

This commit is contained in:
rigani 2018-09-12 18:45:47 +09:00
parent 90982d850e
commit 66bfb37f50

View file

@ -7,6 +7,6 @@ class Integer
# 6.multiple_of?(5) # => false
# 10.multiple_of?(2) # => true
def multiple_of?(number)
number != 0 ? self % number == 0 : zero?
number == 0 ? self == 0 : self % number == 0
end
end