ruby - 为什么我所有的看跌期权都返回=>nil?

标签 ruby null puts

我知道这似乎是一个非常简单的问题,但我的 puts 不断生成“=> nil”让我很困扰,我搜索了答案但找不到答案。谢谢。

puts 'blink ' *4 blink blink blink blink => nil

最佳答案

因为那是puts的返回值:

puts(obj, ...) → nil

Writes the given objects to ios as with IO#print. Writes a record separator (typically a newline) after any that do not already end with a newline sequence. If called with an array argument, writes each element on a new line. If called without arguments, outputs a single record separator.

来源:http://www.ruby-doc.org/core-1.9.3/IO.html#method-i-puts

此外,我假设这只是在 irb 中?因为在正常应用程序中调用 puts 不会显示其返回值。

关于ruby - 为什么我所有的看跌期权都返回=>nil?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14741329/

相关文章:

mysql - 去掉 mysql 查询中的空值

exception - 处理空值的最佳实践是什么?

ruby - 如何为 WordPress 多站点编写 h2o webserver mruby 处理程序?

ruby-on-rails - 运行基本测试时遇到问题(未知属性错误)

ruby - 如何使用 capitalize 方法将字符串数组中的第一个字母大写?

java - 如何在 NULL 上设置 float PreparedStatement (jdbc) 的值

ruby - 为什么 "puts"返回一个空行,而不是 "puts []"?

c - gets() 和 puts() 显示我没有输入的字符

c - 函数 gets() 不会停止接受输入

ruby - 如何使此数组.to_json(Ruby)?它在我的程序中表现不佳,但在irb中工作正常