Last active
March 16, 2018 17:01
-
-
Save nhh/4f4c0a6498308f4401f811168a376b2a to your computer and use it in GitHub Desktop.
Best implementation of divisible by
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Integer | |
def divisible_by?(number) | |
self % number == 0 | |
end | |
end | |
irb(main):054:0> 1.divisible_by? 1 | |
=> true | |
irb(main):055:0> 1.divisible_by? 2 | |
=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment