confused about == vs === in this equality
- To: mathgroup at smc.vnet.net
- Subject: [mg103732] confused about == vs === in this equality
- From: "Nasser Abbasi" <nma at 12000.org>
- Date: Sun, 4 Oct 2009 05:35:38 -0400 (EDT)
- References: <20091003104738.LCJ3I.416659.imail@eastrmwml34>
- Reply-to: "Nasser Abbasi" <nma at 12000.org>
lhs===rhs yields True if the expression lhs is identical to rhs, and yields
lhs==rhs returns True if lhs and rhs are identical.
But looking at this example:
a = ComplexInfinity;
If[a == ComplexInfinity, Print["YES"]]
Expecting it would print "YES", but it does not. it just returns the whole
thing unevaluated? But
If[a === ComplexInfinity, Print["YES"]]
does return YES.
I guess I am a little confused about the "expression" bit in the definition.
So, when using the 3"=", it is looking at the _value_ of the expression, but
when using the 2"=", it is looking at the expression _as it is_, i.e.
without evaluating it? Is this the difference? I've always used the 2"="
for equality, now I have to be more careful which to use.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4478 (20091003) __________
The message was checked by ESET NOD32 Antivirus.
Prev by Date:
Re: Using Mathematica with C++
Next by Date:
Re: on passing arguments to a function, how to break a
Previous by thread:
Re: Prime/Twin Prime Generator
Next by thread:
How to obtain FrameTicks List from an existing Plot?