--- a/SequenceableCollection.st Mon Jul 09 14:55:35 2001 +0200
+++ b/SequenceableCollection.st Tue Jul 10 12:02:29 2001 +0200
@@ -407,6 +407,23 @@
"Modified: / 20.5.1998 / 14:50:25 / cg"
!
+first:n
+ "return the n first elements of the collection.
+ Raises an error if there are not enough elements in the receiver."
+
+ n < 0 ifTrue:[self error:'bad (negative) argument'].
+ n > self size ifTrue:[^ self notEnoughElementsError].
+
+ ^ self copyFirst:n
+
+ "
+ #(1 2 3 4 5) first:3
+ #(1 2 3 4 5) first:6
+ #(1 2 3 4 5) asSet first:3
+ 'hello world' first:5
+ "
+!
+
fourth
"return the fourth element;
report an error, if the collections size is smaller than 4."
@@ -471,6 +488,23 @@
"
!
+last:n
+ "return the n last elements of the collection.
+ Raises an error if there are not enough elements in the receiver."
+
+ n < 0 ifTrue:[self error:'bad (negative) argument'].
+ n > self size ifTrue:[^ self notEnoughElementsError].
+
+ ^ self copyLast:n
+
+ "
+ #(1 2 3 4 5) last:3
+ #(1 2 3 4 5) last:6
+ #(1 2 3 4 5) asSet last:3
+ 'hello world' last:5
+ "
+!
+
nth:n
"return the nth element;
report an error, if the collections size is smaller than n."
@@ -3633,7 +3667,6 @@
"Created: 14.2.1997 / 16:13:03 / cg"
! !
-
!SequenceableCollection methodsFor:'searching'!
detect:aBlock startingAt:startIndex
@@ -5237,6 +5270,6 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.151 2001-05-17 22:36:14 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.152 2001-07-10 10:02:29 cg Exp $'
! !
SequenceableCollection initialize!