Set>>add: should ignore nil argument

lex at cc.gatech.edu lex at cc.gatech.edu
Thu Aug 12 17:54:37 UTC 2004


radoslav hodnicak <rh at 4096.sk> wrote:
> On Thu, 12 Aug 2004, Marcin Tustin wrote:
> 
> >     What if I *want* to store a nil value in a set
> 
> Then you have to find a smalltalk dialect that allows it. In other words,
> check the current Squeak implementation of this method before you start
> trolling.

Yes, but it's not so hard; solutions have been described on USENET
before.

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.

Anyone want to take a crack at it?

-Lex



More information about the Squeak-dev mailing list