MathGroup Archive 2009

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103767] Re: [mg103732] confused about == vs === in this equality
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Mon, 5 Oct 2009 07:39:37 -0400 (EDT)
  • References: <20091003104738.LCJ3I.416659.imail@eastrmwml34>

Hi Nasser,

my guess is that your example represents an exception rather than a rule. It
looks like Equal is internally overloaded (redefined) specifically on
ComplexInfinity (well, may be not only on ComplexInfinity), since you can
not generally say that one ComplexInfinity is equal to another one - they
may have different directions, and in general this may matter.  With SameQ,
it is different since it only tests for symbolic equality - that is, that
lhs and rhs are the same Mathematica expressions - so it yields True.

Regards,
Leonid


On Sun, Oct 4, 2009 at 2:35 AM, Nasser Abbasi <nma at 12000.org> 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.
>
> --Nasser
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4478 (20091003) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
>



  • Prev by Date: Re: Incorrect symbolic improper integral
  • Next by Date: How to find which variable caused the trigger in Manipulate[] ?
  • Previous by thread: Re: confused about == vs === in this equality
  • Next by thread: Re: confused about == vs === in this equality