问题 In Ruby, what is the difference between $stdout (preceded by a dollar sign) and STDOUT (in all caps)? When doing output redirection, which should be used and why? The same goes for $stderr and STDERR . Edit: Just found a related question. 回答1: $stdout is a global variable that represents the current standard output. STDOUT is a constant representing standard output and is typically the default value of $stdout . With STDOUT being a constant, you shouldn't re-define it, however, you can re