Set>>add: should ignore nil argument

radoslav hodnicak rh at 4096.sk
Fri Aug 13 08:11:53 UTC 2004


On Thu, 12 Aug 2004 lex at cc.gatech.edu wrote:

> 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.

The whole point of #add: ignoring nil argument is that it *doesn't add*
nil to the set. Your solution just delays an exception from #add: to #do:
when it iterates over nil (exception in code that relies on the fact that
sets have no nil members). I'm advocating for Set in squeak that can be
used in the same nil-squashing way as in any other smalltalk dialect I've
ever worked with.

rado




More information about the Squeak-dev mailing list