Skip to content

Instantly share code, notes, and snippets.

@mguterl
Created September 28, 2008 15:31
Show Gist options
  • Save mguterl/13473 to your computer and use it in GitHub Desktop.
Save mguterl/13473 to your computer and use it in GitHub Desktop.
def quiet( &block )
io = STDOUT.dup
STDOUT.reopen '/dev/null', 'w'
block.call
STDOUT.reopen io
end
quiet { puts "hello" }
quiet { puts "hello" } # take this out and it works
puts "goodbye"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment