MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: confused about == vs === in this equality

  • To: mathgroup at
  • Subject: [mg103769] Re: confused about == vs === in this equality
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Mon, 5 Oct 2009 13:16:01 -0400 (EDT)
  • References: <20091003104738.LCJ3I.416659.imail@eastrmwml34> <ha9qqp$7vi$>

On 2009.10.04. 12:44, Nasser Abbasi wrote:
> ?===
> 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.

=== tests for structural equivalence, without taking into account any 
mathematical meaning.  It yields True if and only if the FullForm of the 
lhs and rhs look identical.

== tests for mathematical equivalence, AND is also used when writing 
equations.  ComplexInfinity == ComplexInfinity won't give true because 
the phase of ComplexInfinity is undetermined.  Comparing ComplexInfinity 
to a finite number will always give False.

None of the two operators have any Hold* attributes, i.e. the lhs and 
rhs are evaluated before the comparison is performed.

  • Prev by Date: Re: How to obtain FrameTicks List from an existing Plot?
  • Next by Date: Re: What Mathematica "says" on two BBP type infinite sums
  • Previous by thread: Re: Re: confused about == vs === in this equality
  • Next by thread: Re: confused about == vs === in this equality