Login  Register

Re: Can a class be not equal to itself?

Posted by khinsen on Dec 31, 2020; 2:25pm
URL: https://forum.world.st/Can-a-class-be-not-equal-to-itself-tp5125747p5125752.html

On 31/12/2020 12:19, Konrad Hinsen wrote:

> It's been a while since I have encountered mysterious behavior in
> Pharo, but today it happened. I set up a dictionary with classes as
> keys, and got "Key not found" errors for keys that were definitely in
> my dictionary. A quick debugging session showed the underlying issue:
> I had two references to a class which look the same when inspected,
> but turn out to be not identical (==) and thus not equal (=). How can
> this happen?


Update, after a few more debugging sessions: my dictionary is the result
of a deepCopy operation, meaning the class has been copied. And the copy
of a class is indeed a distinct but otherwise indistinguishable class.
'Object copy = Object' is 'false'.


Konrad.