[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] unexpected #indexOf:ifAbsent: result (was What am I

From: Paolo Bonzini
Subject: Re: [Help-smalltalk] unexpected #indexOf:ifAbsent: result (was What am I doing wrong here?)
Date: Tue, 12 Sep 2006 10:03:20 +0200
User-agent: Thunderbird (Macintosh/20060719)

I said this wasn't the finest part of the class library, because (a) you
might reasonably expect #indexOf:ifAbsent: and
#indexOf:matchCase:startingAt: to be variations on a theme, and they're
not; and (b) they're all pretty wordy when all you're wanting to do is
some string wrangling.
Yeah, I remember thinking about the same when I ported this from IBM Smalltalk. Which makes me think it's now exactly 10 years I've been working on GNU Smalltalk. Wow.
My advice, if you are working a lot with strings, is to add a method
like this:

CharacterArray methodsFor: 'syntactic sugar'!

% aSubString
        ^self indexOfSubCollection: aSubString
! !

Now you have:

st> 'a/b' % '/' !
While I agree entirely with you, why the "%"? :-P


reply via email to

[Prev in Thread] Current Thread [Next in Thread]