[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] Easiest way to add new methods to kernel classes (from
[Help-smalltalk] Easiest way to add new methods to kernel classes (from within a script)?
Thu, 25 Feb 2010 14:14:23 -0800
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?
ArrayedCollection subclass: #CharacterArray
| first last collection |
collection := OrderedCollection new.
last := 0.
[first := self findFirst: [ :char | char isSeparator not] startingAt:
last + 1. first ~= 0]
[last := (self findFirst: [ :char | char isSeparator]
first) - 1.
last < 0 ifTrue: [last := self size].
collection add: (self copyFrom: first to: last)].
- [Help-smalltalk] Easiest way to add new methods to kernel classes (from within a script)?,
Rick Flower <=