Identity vs equality (was Re: [Newbies] Assignment)

Andreas Raab andreas.raab at gmx.de
Sun Aug 12 19:21:24 UTC 2007


stephane ducasse wrote:
> But I'm confused do you imply that the order in which the elements were 
> added had an impact on the set?

Yes.

> 
> in VisualWorks
> 

Well, but in VisualWorks also:

String>>= aString
	"Answer whether the argument is a string, and is not a symbol,
	and the receiver's size is the same as aString's size, and each of the 
receiver's
	elements equal the corresponding element of aString"

	| size |
	aString isString ifFalse: [^false].
	aString isSymbol ifTrue: [^false].
	(size := self size) = aString size ifFalse: [^false].
	1 to: size do:[:index | (self at: index) = (aString at: index) ifFalse: 
[^false]].
	^true

So in other words, in VisualWorks Strings and Symbols always compare 
false which is perfectly symmetric.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list