Shouldn't ifEmpty return self?

Ron Teitelbaum Ron at USMedRec.com
Tue Jun 13 01:45:55 UTC 2006


Hey Chris,

I expect nil on ifTrue: or ifFalse: , I'm used to self on ifEmpty: because
that's what VW does (thanks Boris!).

I've always thought of ifNil: and ifEmpty: as the same kind of exception
handler 

aPerson ifNil: [twoPeople makeBaby]

aGasTank ifEmpty: [aGasTank fillerUp. aGasTank]

Or whatever - they are inline exceptions.  I was merging some byteArrays
when I realized that if there were none that I would end up on a collection
instead of an empty byteArray so I tacked on an ifEmpty: [ByteArray new] and
was surprised by the nil when I wasn't empty. 

And as long as we are on the subject I have more:  

What's with indexOf:startingAt: ?

There's an indexOfSubcollection:startingAt:   I have to tack on an ifAbsent:
block to get it to work.  Seems like we should have and indexOf:startingAt:

And how come there is no explode method?  I have subStrings: aDelimiter for
string but nothing for collections?  I wrote one for collections called
explode: anObject but it sure seems like it should have been there
somewhere.  I suggested methods before just to have someone point out the
one I missed, is there an explode like method or something that chops up
collections by some delimiter for collections?

(I'm still cutting my teeth on the differences between VW and Squeak)

Thanks!
Ron

> From: Chris Muller
> Sent: Monday, June 12, 2006 1:30 PM
> 
> It would probably be more consistent with ifTrue: and ifFalse: for
> ifNil: to return nil.
> 
>   false ifTrue: [ 'non-nil' ]   -> nil
> 
> Chris
> 
> --- Ron Teitelbaum <Ron at USMedRec.com> wrote:
> 
> > Shouldn't ifEmpty: return self?
> >
> > #(1) ifEmpty: [nil]  ->      Returns nil
> >
> > #(1) ifNil: [nil].       ->      Returns #(1)
> >
> > Ron Teitelbaum





More information about the Squeak-dev mailing list