--- a/SequenceableCollection.st Sat May 11 11:06:00 1996 +0200
+++ b/SequenceableCollection.st Sat May 11 11:16:03 1996 +0200
@@ -198,6 +198,37 @@
"return the last element"
^ self at:(self size)
+!
+
+upTo:anElement
+ "return a new collection consisting of the receivers elements upTo
+ (but excluding) anElement.
+ If anElement is not in the receiver, the returned collection
+ will consist of all elements of the receiver"
+
+ |pos|
+
+ pos := self indexOf:anElement.
+ pos == 0 ifTrue:[^ self copy].
+
+ ^ self copyFrom:1 to:(pos - 1)
+
+ "
+ #(1 2 3 4 5 6 7 8 9) upTo:5
+ 'hello world' upTo:Character space
+ #(9 8 7 6 5 4 3 2 1) asSortedCollection upTo:5
+
+ raises an error:
+
+ (Dictionary new
+ at:#foo put:'foo';
+ at:#bar put:'bar';
+ at:#baz put:'baz';
+ yourself) upTo:#bar
+
+ "
+
+ "Modified: 11.5.1996 / 11:14:05 / cg"
! !
!SequenceableCollection methodsFor:'adding & removing'!
@@ -2641,5 +2672,5 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.59 1996-05-11 09:06:00 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.60 1996-05-11 09:16:03 cg Exp $'
! !