Yet Another Ruby FizzBuzz その2
class Fixnum def self.fizzbuzzize alias org_to_s to_s def to_s if self%15 == 0 then "FizzBuzz" elsif self%3 == 0 then "Fizz" elsif self%5 == 0 then "Buzz" else self.org_to_s end end end def self.unfizzbuzzize undef to_s alias to_s org_to_s end end Fixnum.fizzbuzzize (1..100).each { |i| print "#{i} " } puts Fixnum.unfizzbuzzize (1..100).each { |i| print "#{i} " }