Can't access objects in dictionary

Amir Ansari fractallyte at csi.com
Fri Dec 31 13:10:58 UTC 2010


Hi Facundo

Thanks for your help.  What I'm trying to understand is how, between different Magma sessions, the Dictionary keys seem to 'lose' their identity.  Obviously, the first thought is that there's something wrong in my code (which I why I posted it all).  Surely it should be simple to check directly whether an object equals a key, without having to define hash methods...?

I ought to point out that I also tested these steps separately without committing in a Magma session, and everything worked OK.

Amir


On Thu, 30 Dec 2010 16:48:32 -0300
Facundo Vozzi <facundov79 at gmail.com> wrote:

> Hi Amir,
> did you define #= method on User ?
> 
> I guest that It'll look like this:
> 
> User >> = otherUser
> "Answer whether the receiver is equal to the argument."
>  self class = otherUser class ifFalse: [^false].
> ^self name = otherUser name
> 
> You need implement the #hash method too:
> 
> User >> hash
> "Answer a SmallInteger whose value is related to the receiver's identity."
>  ^self name hash
> 
> Hope this help.
> 
> Facu


More information about the Magma mailing list