--- a/Collection.st Fri May 06 12:54:42 2016 +0200
+++ b/Collection.st Fri May 06 18:22:39 2016 +0200
@@ -3212,6 +3212,29 @@
"Modified: 20.4.1996 / 11:33:50 / cg"
!
+keysAndValuesDetect:aBlock ifNone:exceptionalValue
+ "for each key-value pair in the receiver, evaluate the argument, aBlock
+ and return the value for which aBlock returns true the very first time.
+ If none of the evaluations returns true, return the result of the
+ evaluation of the exceptionBlock"
+
+ self keysAndValuesDo:[:key :value |
+ (aBlock value:key value:value) ifTrue:[^ value].
+ ].
+ ^ exceptionalValue value
+
+ "
+ |ages|
+
+ ages := Dictionary new.
+ ages at:'cg' put:37.
+ ages at:'ca' put:33.
+ ages at:'sv' put:36.
+ ages at:'tk' put:28.
+ ages keysAndValuesDetect:[:name :age | age = 33].
+ "
+!
+
keysAndValuesDo:aTwoArgBlock
"evaluate the argument, aBlock for every element in the collection,
passing both index and element as arguments.