【发布时间】:2014-01-01 10:35:08
【问题描述】:
使用下面的第一段代码,我收到两条警告消息:
warning: string literal in conditionx2
if input == "N" || "n"
#do this
else input == "L" || "l"
#do this
而不是使用不会导致警告的 this
if input == "N" || input == "n"
#do this
else input == "L" || input == "l"
#do this
我想知道为什么第一段代码会导致警告,以及使用它的缺点。
【问题讨论】:
-
input == "N" || "n"表示(input == "N") || "n"- ruby 很有帮助并说“你做错了”
标签: ruby