For what purpose are there $deferr, $defout and why there is no $defin if there are $stderr, $stdout and $stdin, and also STDIN, STDOUT and STDERR
Changing any of them will not change others
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
STDIN, STDOUT and STDERR are global stream constants (i.e. default values).
$stdin, $stdout and $stderr are global variables initialised to the value of the stream constants. This allows you to change their values at runtime (e.g. to change stdout to an alternative output device).
$defout is a way of creating an ‘in-place’ output stream. There is a brief discussion on the ruby mailing list here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/67822
Obviously you can’t have an in-place input stream, so there is no ‘$defin’.
However, this is mostly for historical interest; I believe $defout and $deferr were deprecated some time ago with the release of Ruby 1.8.2, and current best practice is to use only $stdin, $stdout and $stderr.