Created
June 13, 2013 06:15
-
-
Save ore-public/5771581 to your computer and use it in GitHub Desktop.
metaprogramming fizzbuzz
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 Fixnum | |
def fizzbuzz | |
return :fizzbuzz if self % 15 == 0 | |
return :buzz if self % 5 == 0 | |
return :fizz if self % 3 == 0 | |
self | |
end | |
end | |
(1..100).map {|num| num.fizzbuzz}.each do |num| | |
p num | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment