Set>>add:

Nevin Pratt nevin at smalltalkpro.com
Tue Nov 12 22:58:40 UTC 2002


Richard A. O'Keefe wrote:

>Note that changing Set to quietly *ignore* attempts to add: nil
>would come very close to preventing a change that made add: nil
>work "as expected".  What do the other Smalltalks mentioned actually
>DO when you add: nil to a Set?  Do they add it, or do they just lie?
>
>
>
>  
>

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


Nevin





More information about the Squeak-dev mailing list