NEWBIE Question: == vs =?

Bob Arning arning at charm.net
Wed Jan 24 20:19:15 UTC 2001


On Wed, 24 Jan 2001 12:04:13 -0800 "Phuong Bui" <pbui at mail.worldkey.net> wrote:
>What exactly is the difference between the two boolean mesages: #== and #= ? 
>
>Can someone give an example where #== results in true but not #= ?
>(and vice versa?)

#== answers true if the receiver and argument are the same object.
#= answers true if they are the same object OR they are equivalent, the definition of equivalent being one that can vary from class to class.

Example.

| a b |
a _ 'hello, world'.
b _ a.
a == b. 	"<==== true"
a = b. 	"<==== true"
b _ a copy.
a == b.	"<====  false"
a = b.	"<====  true"

The above answers your vice-versa case. The case of #== being true and #= being false *could* happen if you defined a class where #= returned false when presented with the same object. Why you would want to do that, however, I can't imagine. So the short answer is

#== false and #= true happens a lot.
#== true and #= false probably never happens in real life.

Cheers,
Bob





More information about the Squeak-dev mailing list