Identity vs equality

Craig Latta craig at netjam.org
Fri Aug 10 16:53:38 UTC 2007


Hi Göran--

> Hmmm, odd:
>
> 'Hello' = #'Hello' -> true
>
> #'Hello' = 'Hello' -> false
>
> ...that seems to indicate something is a bit wrong. ;)

     To elaborate on Philippe's answer a little...

     The first expression is asking whether the two are equivalent as
far as the String is concerned. Since the Symbol has the same
characters, the String says yes. The second expression asks the same
question of the Symbol. Since the String is not the same object as the
Symbol, the Symbol says no.

     The rationale used in answering a message is the responsibility of
the receiver; different receivers may have different points of view.


-C

--
Craig Latta
improvisational musical informaticist
www.netjam.org
Smalltalkers do: [:it | All with: Class, (And love: it)]




More information about the Squeak-dev mailing list