【发布时间】:2014-01-01 14:34:42
【问题描述】:
def a
puts 'a'
end
def b
puts 'b'
end
p a || b #=> prints both 'a' and 'b' although it would only print a
p a && b #=> prints only a
发生了什么事?我正在使用 1.9.3
编辑:我忘了 puts 返回 nil,现在这很有意义,感谢第一个答案 :)
【问题讨论】:
-
没什么奇怪的
:puts方法返回nil -
Ups,我忘了这个,现在一切都说得通了。谢谢。
标签: ruby logical-operators puts