SequenceableCollection.st
changeset 17701 ec3c26a0a3b0
parent 17589 eb5555986d10
child 17703 9a1969dcbeb3
--- a/SequenceableCollection.st	Sat Mar 28 09:49:54 2015 +0100
+++ b/SequenceableCollection.st	Sat Mar 28 09:55:27 2015 +0100
@@ -400,7 +400,6 @@
     ^ self == SequenceableCollection
 ! !
 
-
 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
 
 allButFirst
@@ -713,6 +712,7 @@
     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
 ! !
 
+
 !SequenceableCollection methodsFor:'accessing'!
 
 after:anObject
@@ -897,12 +897,20 @@
 
 first:n
     "return the n first 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 copyFirst:n
+
+    "/ OLD:
+    "/ "error if collection has not enough elements"
+    "/ n > self size ifTrue:[
+    "/     ^ self notEnoughElementsError
+    "/ ].
+
+    "/ NEW:
+    "/ return what we have - no error if not enough elements
+    ^ self copyFirst:(n min:self size)
 
     "
      #(1 2 3 4 5) first:3
@@ -9826,11 +9834,11 @@
 !SequenceableCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.404 2015-03-05 12:44:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.405 2015-03-28 08:55:27 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.404 2015-03-05 12:44:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.405 2015-03-28 08:55:27 cg Exp $'
 ! !