class: Behavior
authorClaus Gittinger <cg@exept.de>
Fri, 01 May 2015 11:00:32 +0200
changeset 18309 e26e632b80a7
parent 18307 c1d97d109f88
child 18310 b2a780f62c41
child 18311 efd9abe45fd7
class: Behavior added: #allInstancesForWhich:do:
Behavior.st
--- a/Behavior.st	Wed Apr 29 13:23:35 2015 +0200
+++ b/Behavior.st	Fri May 01 11:00:32 2015 +0200
@@ -1426,6 +1426,7 @@
     ^ self nameWithoutPrefix
 ! !
 
+
 !Behavior methodsFor:'RefactoringBrowser'!
 
 realClass
@@ -4050,6 +4051,23 @@
     "
 !
 
+allInstancesForWhich:predicate do:action
+    "perform action on all instances for which predicate returns true"
+
+    "Read the documentation on why there seem to be no
+     instances of SmallInteger and UndefinedObject"
+
+    self allInstancesDo:[:anObject |
+        (predicate value:anObject) ifTrue:[
+            action value:anObject
+        ].
+    ].
+
+    "
+     ScrollBar allInstancesForWhich:[:s | s shown] do:[:s | Transcript showCR:s topView label]
+    "
+!
+
 allInstancesWeakly:doWeakly
     "return a collection of all my instances.
      If weakly is true, a weak collection is returned."
@@ -5265,9 +5283,10 @@
 !Behavior class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.373 2015-04-26 11:30:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.374 2015-05-01 09:00:32 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.373 2015-04-26 11:30:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.374 2015-05-01 09:00:32 cg Exp $'
 ! !
+