[Newbies] Collection in Smalltalk

Bert Freudenberg bert at freudenbergs.de
Thu Sep 25 15:04:54 UTC 2008


Am 25.09.2008 um 06:40 schrieb Randal L. Schwartz:

>>>>>> "Herbert" == Herbert König <herbertkoenig at gmx.net> writes:
>
> Herbert> Hello Alex,
> AC> Thanks. I'll try to start with the indexing table for each  
> character first.
> AC> Anyway do you know how to split string based on more than 1
> AC> character, for example I want to split string based on some
> AC> punctuation. I have tried using tokenBasedOn, but still can not
> AC> figured out how to use it for more than 1 separator.
>
> String> findTokens: is your friend here.
>
> Herbert> I have a code fragment which reads
>
> Herbert> tokens := comment asLowercase findTokens: mySeparators
>
> Herbert> As I use this fairly often, someplace I have code to  
> initialise
> Herbert> mySeparators like:
>
> Herbert> mySeparators := Array new: 13
> Herbert> mySeparators at: 1 put: $- ; at: 2 put: $( .....
> Herbert> and so on.
>
> You can just write that as a literal:
>
>  mySeparators := #($- $().


Err, what's wrong with using a String?

	mySeparators := '-(...'

- Bert -




More information about the Beginners mailing list