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: [mg103756] Re: [mg103732] confused about == vs === in this equality
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Mon, 5 Oct 2009 07:37:30 -0400 (EDT)
  • References: <20091003104738.LCJ3I.416659.imail@eastrmwml34>
  • Reply-to: drmajorbob at yahoo.com

Examples:

a = ComplexInfinity;
a == ComplexInfinity
a === ComplexInfinity

ComplexInfinity == ComplexInfinity

True

a is identical to ComplexInfinity, but it isn't Equal to it, because  
ComplexInfinity is an indeterminate form, not Equal to anything... not  
even itself.

Clear[a, b]
a == b
a === b

a == b

False

Mathematic doesn't know the values of a and b, so it doesn't know whether  
a is equal to b, hence a == b remains unevaluated. But Mathematica DOES  
know a and b are not identical.

a == a
a === a

True

True

No matter what value "a" might have (OTHER THAN AN INDETERMINATE FORM), a  
== a is True. Mathematic is assuming "a" ISN'T indeterminate, even though  
it could be.

Meanwhile, a === a because any expression is identical to itself.

Bobby

On Sun, 04 Oct 2009 04:35:38 -0500, 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
>
>
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: How to find which variable caused the trigger in Manipulate[] ?
  • Next by Date: Re: Placing images in the coordinate system?
  • Previous by thread: Re: confused about == vs === in this equality
  • Next by thread: Re: confused about == vs === in this equality