Aug. 19, 2010
4:30 p.m.
What's the best (most elegant/efficient...) way to insert a string into another string at a given index? Say I have the string 'Toto-Tata-Titi' and I want to build the string 'Toto-Tests-Tata-Titi' I could think of the following: | string sepIndex stream | string := 'Toto-Tata-Titi'. sepIndex := string indexOf: $-. stream :=String new writeStream. stream nextPutAll: (string copyFrom: 1 to: sepIndex). stream nextPutAll: 'Tests'. stream nextPutAll: (string copyFrom: sepIndex to: string size). ^ stream contents Any suggestion? -- Simon
5825
Age (days ago)
5825
Last active (days ago)
0 comments
1 participants
participants (1)
-
Simon Denier