--- a/Collection.st Sat May 07 12:30:11 2016 +0200
+++ b/Collection.st Sat May 07 12:32:29 2016 +0200
@@ -3235,6 +3235,29 @@
"
!
+keysAndValuesDetectKey:aBlock ifNone:exceptionalValue
+ "for each key-value pair in the receiver, evaluate the argument, aBlock
+ and return the key/index 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:[^ key].
+ ].
+ ^ 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 keysAndValuesDetectKey:[:name :age | age = 33] ifNone:nil.
+ "
+!
+
keysAndValuesDo:aTwoArgBlock
"evaluate the argument, aBlock for every element in the collection,
passing both index and element as arguments.