The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
$stdout vs STDOUT

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Hodel

Posts: 660
Nickname: drbrain
Registered: Mar, 2006

Eric Hodel is a long-time Rubyist and co-founder of Seattle.rb.
$stdout vs STDOUT Posted: Aug 17, 2006 9:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Hodel.
Original Post: $stdout vs STDOUT
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Hodel
Latest Posts From Segment7

Advertisement

You may have noticed me using both $stdout and STDOUT in my last post and been puzzled by how I could use both.

When Ruby starts up the process’ standard output file descriptor is stored in both the constant STDOUT and the global variable $stdout. STDOUT holds the process’ original stdout while $stdout is reassignable. Kernel#puts and friends use $stdout for to write their output, not STDOUT.

To be most-friendly, when you want to redirect stdout you should assign to $stdout instead of fiddling with STDOUT. When outputting to an explicit file descriptor, use $stdout or $stderr instead of STDOUT or STDERR.

STDOUT can only be changed by calling IO#reopen, but you can assign any object that responds to #write to $stdout, which is what made my ThreadOut hack work.

Read: $stdout vs STDOUT

Topic: Sun al fin da una fecha para liberar a Java como Open Source Previous Topic   Next Topic Topic: Scriptaculous Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use