Set>>add: should ignore nil argument

Chris Muller afunkyobject at yahoo.com
Fri Aug 13 02:47:05 UTC 2004


> My favorite simple solution is to add an instance variable to Set named
> "includesNil".  If you add nil to a set, set the variable to true.  If
> you remove it, set it to false.  Have #do: check that variable and
> iterate over nil if it's there. And so on.

What do you think of using a unique Object new instead of nil as the "empty
slot" indicator?..  Hmm...  It would have to enumerate the much or all of the
array to do the assignment each time it grew, but that's pretty fast, isn't it?




More information about the Squeak-dev mailing list