Using the first bit of code below I receive two warning messages:
warning: string literal in condition
x2
if input == \"N\" || \"n\"
#do this
else
When you are writing input == "N" || "n"
( internally Ruby sees it (input == "N") || "n"
), it means "n"
string object is always a truth value. Because in Ruby every object is true
, except nil
and false
. Ruby interpreter is warned you there is not point to put ever true value is conditional checking. Conditional check statement always expect equality/un-equality test kind of expression. Now you can go ahead this way or re-think again. if input == "N" || input == "n"
is not throwing any warning, as it obeys the norm of conditional test.
else input == "L" || "l"
is wrong, as else statement don't expect any conditional test expression. Change it to elseif input == "L" || "l"