added #truncateTo:
authorClaus Gittinger <cg@exept.de>
Fri, 26 Jan 2001 17:06:10 +0100
changeset 5795 d67a8ff4d98e
parent 5794 9fc321e3906a
child 5796 6f5c56b1aca4
added #truncateTo:
CharacterArray.st
--- a/CharacterArray.st	Fri Jan 26 17:03:08 2001 +0100
+++ b/CharacterArray.st	Fri Jan 26 17:06:10 2001 +0100
@@ -2444,6 +2444,21 @@
     ^ self lastIndexOfSeparator
 !
 
+truncateTo:smallSize
+    "return myself or a copy shortened to smallSize.  1/18/96 sw"
+
+    self size <= smallSize ifTrue:[^ self].
+    ^ self copyFrom: 1 to: smallSize
+
+    "
+     'hello world' truncateTo:5 
+     'hello' truncateTo:10      
+
+     'hello world' copyTo:5       
+     'hello' copyTo:10
+    "
+!
+
 withBlanksTrimmed
     "Return a copy of the receiver from which leading and trailing blanks have been trimmed."
 
@@ -5792,6 +5807,6 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.199 2001-01-26 16:03:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.200 2001-01-26 16:06:10 cg Exp $'
 ! !
 CharacterArray initialize!