[ENH] String>>findBetweenSubStrs: comment (was Re: [ADDITION] String >> subStrings:)

Doug Way dway at riskmetrics.com
Wed Nov 15 20:09:49 UTC 2000


Bolot Kerimbaev wrote:
> 
> On Wed, Nov 15, 2000 at 12:31:29AM -0500, Doug Way wrote:
> >
> > Actually, not only does a method exist in the base image which does
> > this, but there seem to be two methods which do basically the same thing:
> >
> > String>>findTokens:
> > String>>findBetweenSubStrs:
> >
> 
> Actually, these appear to be very different. Consider this:
> 
> 'abra cadabra machina rabota' findBetweenSubStrs: {'ra'}
> an OrderedCollection('ab' ' cadab' ' machina ' 'bota')
> 
> 'abra cadabra machina rabota' findTokens: {'ra'}
> an OrderedCollection('abra cadabra machina rabota')
> 
> 'abra cadabra machina rabota' findTokens: 'ra'
> an OrderedCollection('b' ' c' 'd' 'b' ' m' 'chin' ' ' 'bot')

Ah, I figured there was probably a meaningful difference that I was missing.

It hadn't even occured to me that either method would accept a collection of strings.  In my defense, the comment for findBetweenSubStrs: is very unclear about what exactly is expected as a parameter.  (Although the method which findBetweenSubStrs: calls (findAnySubStr:) does have a better comment.)  The parameter for both findTokens:/findBetweenSubStrs: is called 'delimiters', which led me to believe that they were equivalent.

It would appear that #findTokens: expects either a single Character, or a collection of Characters (a.k.a. a String, but in this case it's better to think of it as a collection of Characters).  It will let you pass in a collection of Strings without error (as in your example above), but it won't work... an error would probably be better.

#findBetweenSubStrs: expects either a collection of Characters, or a collection of Strings.  It does barf if you pass it a single Character, which is probably good.

Anyway, the comment for findBetweenSubStrs: could be a lot more clear, so I'm submitting a version with a better comment.  (Ideally these methods should be changed/refactored so that they don't overlap each other in functionality... probably findBetweenSubStrs: should *not* accept a collection of Characters.)

- Doug Way
  dway at riskmetrics.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findBtwSubStrsComment-dew.cs
Type: application/x-unknown-content-type-cs_auto_file
Size: 961 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20001115/c1129693/findBtwSubStrsComment-dew.bin


More information about the Squeak-dev mailing list