Paolo,

I'd like to add >>asArrayOfSubstrings (found in the Smalltalk 
by Example book) into the CharacterArray class but would like
it to remain within my script so that I don't modify the kernel
files directly.. What's the best way to do that?  I tried adding
it to the top of my script file like shown below but GST wasn't
too happy about it.. Do I need to convert over to the new style
syntax to do this sort of thing or something else?

#!/usr/local/bin/gst -f 

ArrayedCollection subclass: #CharacterArray
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Collections-Text'!
        
    asArrayOfSubstrings [
    <category: 'converting'>
        | first last collection |
        
        collection := OrderedCollection new.
        last := 0.
        [first := self findFirst: [ :char | char isSeparator not] startingAt:
last + 1. first ~= 0]
                whileTrue: 
                        [last := (self findFirst: [ :char | char isSeparator] 
startingAt:
first) - 1.
                        last < 0 ifTrue: [last := self size].
                        collection add: (self copyFrom: first to: last)].
        ^collection asArray
! !

.
.
.



_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to