A while ago I posted this problem
“When I run this code it works
if('a'=='b'){run some code}
but as soon as I add an or operator it runs the code every time whether there is a match or not.
if('a'=='b'||'c'){run some code}
The code now runs for all values of a.”
The kind replies given seemed to solve the problem at the time but now I am not so sure.
One post received from wilku read
“Yep, ('a'=='b'||'c') evaluates as true because 'c' is evaluated as true, therefore you have "('a'=='b') or true" which is always true.”
On rereading this post I am again very puzzled.
It reads in part “because 'c' is evaluated as true”.
My question is why is ‘c’ evaluated as true? The premise it represents could quite easily be false.
Secondly if ‘a’ is not equal to ‘b’ then (‘a’==’b’) would evaluate to false and hence
"('a'=='b') or true"
would evaluate to “false or true” which in turn must surely evaluate to false
Truth tables do not seem to be my strong point.