findFirst: refactored
authorClaus Gittinger <cg@exept.de>
Mon, 18 May 2009 16:48:05 +0200
changeset 2145 5ceaed7530fe
parent 2144 c89258333f4d
child 2146 241ff257121b
findFirst: refactored
Iterator.st
--- a/Iterator.st	Thu May 07 15:26:59 2009 +0200
+++ b/Iterator.st	Mon May 18 16:48:05 2009 +0200
@@ -311,15 +311,15 @@
     block value: aBlock
 !
 
-findFirst: aBlock
+findFirst: aBlock ifNone:exceptionalValue
     "Answer the index of the first element of the receiver
     for which aBlock evaluates as true."
 
     | index |
+
     index := 1.
     self do: [ :el | (aBlock value: el) ifTrue: [^index].  index := index + 1].
-
-    ^0
+    ^exceptionalValue value
 !
 
 findLast: aBlock
@@ -391,5 +391,5 @@
 !Iterator class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.19 2007-03-15 15:24:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.20 2009-05-18 14:48:05 cg Exp $'
 ! !