--- a/SequenceableCollection.st Sat Mar 28 09:55:33 2015 +0100
+++ b/SequenceableCollection.st Sat Mar 28 10:01:41 2015 +0100
@@ -994,18 +994,21 @@
last:n
"return the n last elements of the collection.
- Raises an error if there are not enough elements in the receiver."
+ No longer raises an error if there are not enough elements;
+ instead, returns what is there."
n < 0 ifTrue:[self error:'bad (negative) argument'].
- n > self size ifTrue:[^ self notEnoughElementsError].
-
- ^ self copyLast:n
+ "/ OLD:
+ "/ n > self size ifTrue:[^ self notEnoughElementsError].
+
+ ^ self copyLast:(n min:self size)
"
#(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
+ 'hello' last:10
"
!
@@ -9834,11 +9837,11 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.405 2015-03-28 08:55:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.406 2015-03-28 09:01:41 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.405 2015-03-28 08:55:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.406 2015-03-28 09:01:41 cg Exp $'
! !