Possible Duplicate:
Ruby $stdout vs. STDOUT
Is STDERR generally preferred over using $stderr, or vice versa?
And what about STDOUT vs $stdout?
To the contrary, using $stderr is preferrable.
The reason for that is that $stderr as a global variable can be reassigned, while STDERR as a constant shouldn't be reassigned (it raises a warning).
Usually they both point to the same standard error file, but in some cases you might want to temporarily redirect all your output somewhere else (for example, to a log file or into a string buffer), in which case you can just reassign $stderr and all your code will respect that (if you were smart enough to use $stderr instead of STDERR in the first place).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With