Skip to content

Instantly share code, notes, and snippets.

Created February 9, 2009 13:39
Show Gist options
  • Save anonymous/60784 to your computer and use it in GitHub Desktop.
Save anonymous/60784 to your computer and use it in GitHub Desktop.
require 'stringio'
old_stdout, new_stdout = $stdout, StringIO.new
$stdout = new_stdout
puts "Hello, World!"
$stdout = old_stdout
puts new_stdout.string
# >> Hello, World!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment