In Smalltalk, if the string 'OneTwoThree' is given, I would like to remove the last part of Three 'OneTwoThree' . 'Three' . 'OneTwo' , In Squeak method finder: 'OneTwoThree' . 'Three' . 'OneTwo' 'OneTwoThree' . 'Three' . 'OneTwo' 'OneTwoThree' . 'Three' . 'OneTwo' .
The best I can come up with is:
'OneTwoThree' allButLast: 'Three' size ,
but it does not feel very Smalltalk-ish because it uses the length of the substring, not the substring. How do you code it?
smalltalk
nes1983
source share