Created
November 11, 2013 22:19
-
-
Save JohnColvin/7421515 to your computer and use it in GitHub Desktop.
monkey patch fizz buzz
This file contains hidden or 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?(i) | |
| self%i === 0 | |
| end | |
| def fizzbuzz | |
| fizz + buzz | |
| end | |
| def fizz | |
| divisible_by?(3) ? 'fizz' : '' | |
| end | |
| def buzz | |
| divisible_by?(5) ? 'buzz' : '' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment