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

前端之家收集整理的这篇文章主要介绍了ruby – 为什么我所有的回报=> nil?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这可能看起来像一个非常简单的问题,但是我真的困扰我,我的投注继续产生“= nil”,我搜索了一个答案,却找不到答案.谢谢. @H_404_2@ @H_404_2@

puts ‘blink ‘ *4
blink blink blink blink
=> nil

解决方法

因为这是puts的返回值: @H_404_2@

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在正常应用程序中不显示其返回值.

原文链接:https://www.f2er.com/ruby/268810.html

猜你在找的Ruby相关文章