2016-11-01 12:39 GMT-03:00 Joachim Tuchel <jtuc...@objektfabrik.de>:

> I know. That's exactly the reason why I never use isEmptyOrNil
>
> Fun aside: how often do we need to check if some code returns nil or an empty 
> collection. My question was aimed at exactly this: in practice ifEmptyOrNil: 
> would probably be even more frequently needed than ifEmpty:. Otherwise, the 
> beautiful convenience method has to be guarded by a nil test.... so we end up 
> writing lots of methods, and not all of them seem to be universal enough to 
> be part of the base image, imo.

To start with <http://wiki.c2.com/?NullConsideredHarmful>, and then...
the best way to avoid testing for nil, is to not use it at all!
Wherever possible a Null Object (as in
<http://wiki.c2.com/?NullObject>) is a great replacement.

It is, using a domain specific UndefinedObject instead of the default nil.


Regards,

Esteban A. Maringolo

Reply via email to