On 6/3/07, Peter Seebach <seebs / seebs.net> wrote: > My solution, which is probably awkward in its use of method mangling: > > class Fixnum > @@old_to_s = 1.method(:to_s).unbind > def to_s > s = ((self % 3 == 0 ? "Fizz" : "") + (self % 5 == 0 ? "Buzz" : "")) > s.empty? ? @@old_to_s.bind(self).call : s > end > end > > (1..100).each { |x| p x } > > I wouldn't be surprised at all to find that there's a much cleaner way > to accomplish the override. The curious reader will note that this could > be shortened somewhat if we had something like that "it" feature some > were discussing. > > -s > > My solution (see other thread) uses a lot of those same techniques. My method was overriding #inspect instead of #to_s, so you don't need to do anything crazy. Or you could just use an alias... :) -- Chris Carter concentrationstudios.com brynmawrcs.com