I'm trying to test the following logical statement:
state = {{1,1,1}};
Or[state != 0, state != Null]
but it's returning False
rather than True
as I expect it to.
I ran the following TrueQ
tests, getting the following results:
TrueQ[Or[{{1, 1, 1}} != 0, {{1, 1, 1}} != Null]]
TrueQ[{{1, 1, 1}} != 0]
TrueQ[{{1, 1, 1}} != Null]
False
False
False
I'm not sure why I'm getting these results: I don't understand why TrueQ
is failing to resolve as True
in these situations. What can I do to make the logical test give me the results I'm looking for -- namely, when state
is either 0
or Null
, I get False
, and get True
otherwise?
=!=
instead of!=
. $\endgroup$TrueQ
at all?{{1, 1, 1}} =!= 0
evaluates toTrue
directly. $\endgroup$TrueQ
returnsTrue
if and only if its argument is identically equal toTrue
. Now{{1, 1, 1}} != Null
remains unevaluated and hence is notTrue
, which meansTrueQ
returnsFalse
. $\endgroup$