答案 0 :(得分:2)
您的猜测是完全正确的。这是一个段落,其中同时使用了ios
和I/O streams
这两个术语:https://ruby-doc.org/core-2.5.0/IO.html#method-i-close
希望对您有所帮助。
答案 1 :(得分:2)
无论您在以下哪个位置拨打puts
:
$stderr.puts("Hello from Standard Error") # $stderr is IO
puts("Hello from Kernel") # main is IO
File.new("/tmp/foo").puts("bar") # File is IO
任何从IO
(或Kernel
)继承的内容都会对puts
做出响应。
$stderr.class.ancestors # => [IO, File::Constants, Enumerable, Object, Kernel, BasicObject]
self.class.ancestors # => [Object, Kernel, BasicObject]
File.ancestors # => [File, IO, File::Constants, Enumerable, Object, Kernel, BasicObject]