From 66bfb37f50cfee0acf607c5dda39fd55a3ee3f50 Mon Sep 17 00:00:00 2001 From: rigani Date: Wed, 12 Sep 2018 18:45:47 +0900 Subject: Faster multiple_of? method --- activesupport/lib/active_support/core_ext/integer/multiple.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/core_ext/integer/multiple.rb b/activesupport/lib/active_support/core_ext/integer/multiple.rb index e7606662d3..bd57a909c5 100644 --- a/activesupport/lib/active_support/core_ext/integer/multiple.rb +++ b/activesupport/lib/active_support/core_ext/integer/multiple.rb @@ -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 -- cgit v1.2.3