Set>>add:

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu Nov 14 01:32:47 UTC 2002


Nevin Pratt <nevin at smalltalkpro.com> wrote:
	Here's the VisualWorks implementation of Set>>add:
	
	add: newObject
	    "Include newObject as one of the receiver's elements.
	     Answer newObject."
	
	    | index |
	    newObject == nil ifTrue: [^newObject].
	    index := self findElementOrNil: newObject.
	    (self basicAt: index) == nil ifTrue: [self atNewIndex: index put: 
	newObject].
	    ^newObject
	
The really interesting thing here is that the comment and the code
DO NOT AGREE.  The comment says nothing whatsoever about nil being
forbidden.

What happens to GLORP on the day when someone rewrites the code so that
it does what the comment says it does?




More information about the Squeak-dev mailing list