[Cuis-dev] String vs Symbol objects

Mark Volkmann r.mark.volkmann at gmail.com
Wed Jul 17 06:24:55 PDT 2024


I understand that Symbols are globally unique and I thought Strings are not.
But I'm confused by this code:

sym1 := #test.
sym2 := #test.
self assert: sym1 = sym2. "passes"
self assert: sym1 == sym2. "passes"

str1 := 'test'.
str2 := 'test'.
self assert: str1 = str2. "passes"
self assert: str1 ~~ str2. "FAILS"

Why does the last line fail?
I thought that str1 and str2 would refer to different objects in memory.

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240717/cc9af362/attachment.htm>


More information about the Cuis-dev mailing list