Search code examples
smalltalkpharo

How do I test for equality between an Array of associations and an Object (instance) in Pharo Smalltalk?


I have this small piece of code which doesn't seem to work and test weather the objects are one and the same.

something := ((selectedTab value) ==  registerObject).

or:

((selectedTab value) ==  registerObject) ifTrue: [ "this never get's executed" ]

I've "Explored pointer" on both instances "selected value" has the exact same id as "registerObject" and I've even put in parenthesis to boot.

Can anyone enlighten me on the subject?


Solution

  • SelectedTab was an Array or 'name' -> object associations with just one such association. I was convinced it was storing just the object itself.

    I had to use first value instead of just value:

    something := ((selectedTab first value) ==  registerObject).
    
    ((selectedTab first value) ==  registerObject) ifTrue: [ "this never get's executed" ]
    

    Rookie mistake everyone!!! I raised hell for nothing.