可能性の重複:Rubyで
Ruby: difference between || and 'or'ルビブール演算子または||違い
、ではありません 'または' と '||'同じこと?私はコードを実行すると異なる結果になります。
line =""
if (line.start_with? "[" || line.strip.empty?)
puts "yes"
end
line =""
if (line.start_with? "[" or line.strip.empty?)
puts "yes"
end
だから、最初のステートメントは( "[" || line.strip.empty?)= "["と評価され、次に(line.start_with? "[")と評価されます。 – surajz
まさにそうです。優先順位は、括弧のように、省略時の意味を推測する方法です。ちょうど数学の優先順位のように働く。 –