Re: confused about == vs === in this equality
- To: mathgroup at smc.vnet.net
- Subject: [mg103747] Re: confused about == vs === in this equality
- From: "Chris Degnen" <degnen at cwgsy.net>
- Date: Mon, 5 Oct 2009 07:35:49 -0400 (EDT)
- References: <20091003104738.LCJ3I.416659.imail@eastrmwml34> <ha9qqp$7vi$1@smc.vnet.net>
I refer you to Leonid's Mathematica introduction: http://www.mathprogramming-intro.org/book/node109.html "Nasser Abbasi" <nma at 12000.org> asked: > > ?=== > lhs===rhs yields True if the expression lhs is identical to rhs, and > yields > False otherwise. > > ?== > 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. > > --Nasser >