This is not about taste. This is about not promoting the use of nil or
dependency or the meaning of empty collection.

A better way is to look at the upstream logic and modify that one so that
it does not need to know about nil or empty.

Cheers,
Doru



On Mon, Jan 5, 2015 at 1:17 PM, Sebastian Sastre <
[email protected]> wrote:

> taste is taste but would you care to illustrate your point with examples?
> I’m curious about it
>
>
>
> > On Jan 5, 2015, at 6:12 AM, stepharo <[email protected]> wrote:
> >
> > You summarise well the kind of code I do not like.
> > isNil everywhere and horrible tests.
> >
> > Stef
> >
> >
> > Le 4/1/15 23:27, Sebastian Sastre a écrit :
> >> Hi guys,
> >>
> >> I’ve started to use this little one:
> >>
> >> Object>>ifNilOrEmpty: aBlock
> >>
> >>      self ifNil: [ ^ aBlock value ].
> >>
> >>      (self isCollection and: [
> >>      self isEmpty ]) ifTrue: [ ^ aBlock value ].
> >>
> >>      ^ self.
> >>
> >>
> >> It allows you to do the widely known JavaScript one-liner:
> >>
> >> var stuff = this.thing || ‘some default value for when this.thing is
> undefined, null or an empty string’.
> >>
> >> but in smalltalk in this way:
> >>
> >> stuff := self thing ifNilOrEmpty: [ ‘some default value for when self
> thing is nil or an empty string’ ]
> >>
> >> simple thing feels practical and nice :)
> >>
> >>
> >>
> >
> >
>
>
>


-- 
www.tudorgirba.com

"Every thing has its own flow"

Reply via email to