【问题标题】:What is "ios" in the Ruby documentation for puts?puts 的 Ruby 文档中的“ios”是什么?
【发布时间】:2018-08-15 18:28:15
【问题描述】:

iOS 已经为这个问题提供了良好的搜索结果。 The Ruby docs for puts说吧

将给定对象写入 ios。

什么是“ios”。我最好的猜测是它是“输入/输出流”,但不确定这是否有意义。

【问题讨论】:

  • 你的猜测是对的,而且是有道理的。

标签: ruby puts


【解决方案1】:

你的猜测完全正确。这是一段同时使用了iosI/O streams这两个术语的段落:https://ruby-doc.org/core-2.5.0/IO.html#method-i-close 希望对您有所帮助。

【讨论】:

    【解决方案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]
    

    【讨论】:

      猜你喜欢
      • 2012-02-18
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 2010-10-11
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多