ifNil, ifNotNil

Michael Lucas-Smith ich at driftwood.darktech.org
Thu Aug 3 23:06:20 UTC 2000


Eric Arseneau wrote:

> > > I, too, years ago implemented ifNotNil: with an optional argument.
> > >
> > > For Squeak, I happily use ifNotNilDo:.  It is not as generic,
> > but it saves
> > > an argument count test.  Now if only it were transformed, too...
> >
> > Hi Jim,
> >
> > I will work on the transform now.  The transform will get rid of the need
> > for testing for 0 vs 1 arguments.
> >
> > I am assuming that no one will mind and sees no problems with this ???
>
> I just looked at some of the code.  It gets kind of hairy in there.  I'm not
> willing to make these changes unless I have a more recent image and I think
> I'm in a 2.8.  So I will wait till I have some bigger cohonas ;->
>
> For now I'll just do a search and replace and use ifNotNilDo:
>
> Chickened out ...

I always thought it would be a nice idea to have

ifNil:ifNotNil: and ifNotNil:ifNil:

usually the situations come from...
could possibly have a value, if we dont, use a default value (ifNil:)
want to do something if we have a value,  but want to ignore it if it's nil
(ifNotNil:)
want to do something if it's nil (some sort of failed contract) and do
something else if it's not nil (ifNil:ifNotNil:) ...

Just a thought of mine.

Michael.





More information about the Squeak-dev mailing list