Ruby has constants and global variables for stdio.
Namely, consts STDIN, STDOUT, STDERRand their variables, $stdin, $stdout, $stderr.
I understand the difference between constant and variable. I know that constants are invariably set to file descriptors at the moment the script was exec'd.
I also understand that you can change (some) variables at runtime.
I am curious about the practical use of such a function. Why would you do this? What can you achieve?
Seeing sample code or even just used cases extracted from real-world projects would be great.
Update . From what I am collecting so far, it seems that when writing your own libraries / programs, you should use variables over constants so that its users can deal with it, Right?
source
share