Thanks Ron.  That was interesting to look into but I wasn't clear with my query.  It was not so much with the equality comparison but with the difference in the assignment to (x) and (y) between the two examples and the second item of the resulting OrderedCollection (which I have changed to upper caps).

I had thought that the two assignments of 'xxx' to (x) and (y) would result in different objects, but they turn out to be identical.  It is like the compiler has noticed that they are equal and chosen to make them identical.  Then again, perhaps as literals they can be considered identical - just not what I was expecting.

cheers, Ben

Ron Teitelbaum wrote:
Hi Ben,

Have a look at the method for yourself.  Check out the method = on the
instance side of String. 

It should be pretty obvious when you get to the actual string comparison.

All the best,

Ron Teitelbaum

  
-----Original Message-----
From: beginners-boun...@lists.squeakfoundation.org [mailto:beginners-
boun...@lists.squeakfoundation.org] On Behalf Of Ben Coman
Sent: Saturday, January 07, 2012 12:15 AM
To: A friendly place to get answers to even the most basic questions about
Squeak.
Subject: [Newbies] Testing = and == in workspace

I was trying to confirm the operation of = and == in the workspace by
executing the following code..

x :=  'xxx'.
y :=  'xxx'.
z := x.
(OrderedCollection new) add: (x = y) ; add: (x == y) ; add: (x=z); add:
(x==z); yourself.

I was confused that I was getting anOrderedCollection(true TRUE true true)

It was not until I changed to the following code...

x := String newFrom: 'xxx'.
y := String newFrom: 'xxx'.
z := x.
(OrderedCollection new) add: (x = y) ; add: (x == y) ; add: (x=z); add:
(x==z); yourself.

that I got the expected anOrderedCollection(true FALSE true true)

I was curious what was going on in the first case.

cheers, Ben
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
    

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

  

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to