> On Jan 5, 2015, at 2:56 PM, Henrik Johansen <[email protected]> 
> wrote:
> 
> Of course, you can still do nonsense like
> stuff := aCollection ifNilOrEmpty: [42]
> but at least *that* problem is easier to pinpoint when later, a debugger with 
> a user of stuff that expected it to be a collection pops up.
> If the origin of stuff as a single instance is lost to the mists of time 
> (say, Object implements ifNilOrEmpty: and someone called stuff: with an 
> Object without error), it's easier to end up with a solution of "fixing" the 
> use to
> (stuff isKindOf: Collection) "or is that isCollection?"
>       ifTrue: ["Code handling each entry"] 
>       ifFalse: ["Code handling single instance"]
> 
> And now there's two stinks.
> 
> Cheers,
> Henry

Ah, right. I get your point now. 

I'd see that as an abuse.

I’ve mentioned a couple of examples before, the “good” uses of this convenience 
are meant for handling the empty string or nil frequent case and APIs that are 
more functionally inspired (like when they use an Option / Some / None / 
Nothing as response and you need to normalize that into smalltalk style)


Reply via email to