[ADDITION] String >> subStrings:

Norton, Chris chrisn at Kronos.com
Thu Nov 16 01:12:34 UTC 2000


Hi Ali & company!

I was very surprised to find your e-mail on this subject, as parsing strings
is such a common task.  But, fortunately, as Doug Way pointed out, there
ways to "skin this cat" in Squeak (e.g. #findTokens:).

I suppose all Smalltalks are somewhat different in their naming conventions,
but I feel obliged to point out Visual Smalltalk Enterprise's name for this
kind of operation -- when you are parsing a string and you have only one
token (a single delimiter character).

VSE implements the following String methods:
    asArrayOfSubstrings
    asArrayOfSubstringsSeparatedBy:

The first one is similar to Squeak's #substrings method (it returns a Array
of substrings, using the a space character as the default delimiter).  The
second method takes a single character as the delimiter.  Both VSE methods
return Arrays of substrings.  The Squeak #substrings method returns an
OrderedCollection of substrings.

In any event, I recommend naming your new method #substrings: or
#substringsSeparatedBy: for consistency sake.

Just tossing in my 2 bits...

Cheers,

---==> Chris

PS>  Your method runs faster than the VSE's implementation of this method.
Nice work!  :-)





More information about the Squeak-dev mailing list