加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – 为什么我所有的回报=> nil?

发布时间:2020-12-17 04:24:52 所属栏目:百科 来源:网络整理
导读:我知道这可能看起来像一个非常简单的问题,但是我真的困扰我,我的投注继续产生“= nil”,我搜索了一个答案,却找不到答案.谢谢. puts ‘blink ‘ *4 blink blink blink blink = nil 解决方法 因为这是puts的返回值: puts(obj,…) → nil Writes the given obj
我知道这可能看起来像一个非常简单的问题,但是我真的困扰我,我的投注继续产生“= 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在正常应用程序中不显示其返回值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读