diff -r d99e4a2e6a4b -r 25a3fac40fce OrderedDictionary.st --- a/OrderedDictionary.st Mon Sep 30 14:02:37 2019 +0200 +++ b/OrderedDictionary.st Tue Oct 01 09:29:58 2019 +0200 @@ -829,6 +829,22 @@ self from:firstIndex to:lastIndex do:aBlock. ! +doWithIndex:aBlock + "like keysAndValuesDo:, but passes the index as second argument. + Same as withIndexDo:, due to parallel evolution of different Smalltalk dialects" + + order doWithIndex: [:key :idx | aBlock value:(self at: key) value:idx ] + + " + |d| + d := OrderedDictionary new. + d at:'z' put:'ZZZ'. + d at:'b' put:'BBB'. + d at:'a' put:'AAA'. + d doWithIndex:[:val :idx | Transcript showCR:'idx: %1 val: %2' with:idx with:val]. + " +! + findFirst:aBlock ifNone:exceptionalValue "Return the index of the first association in the dictionary for which aBlock evaluates as true. If the block does not evaluate to true, return exceptionalValue"