From: Matthias Reitinger Date: 2008-08-23T05:12:43+09:00 Subject: Re: temporarily redefine the 'puts' command? aidy wrote: > Is it possible to temporarily redefine the 'puts' command? I would suggest to reassign $stdout instead. This ensures that print, putc et cetera won't output anything either. --- class DevNull; def write(*args) end end $stdout = DevNull.new puts "This output will be discarded." $stout = STDOUT puts "And this one won't!" --- You could even wrap this up in a nice helper method: --- class DevNull; def write(*args) end end module Kernel def silent $stdout = DevNull.new yield $stdout = STDOUT end end silent do puts "Nothing to see here..." print "... and there!" end --- Regards, Matthias -- Posted via http://www.ruby-forum.com/.