File tree Expand file tree Collapse file tree
Collections-Sequenceable-Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -874,6 +874,15 @@ OrderedDictionaryTest >> testEqualsWhenKeyArentInTheSameOrder [
874874 assertDictionary: dictionaryOne doesNotEqual: dictionaryTwo.
875875]
876876
877+ { #category : ' testing' }
878+ OrderedDictionaryTest >> testFlatCollect [
879+
880+ | res |
881+ res := {#first - > - 1 . #second - > 5 . #three - > - 33 } as: OrderedDictionary .
882+ res := res flatCollect: [ :e | { e abs } ].
883+ self assert: res asSet equals: #(1 5 33) asSet
884+ ]
885+
877886{ #category : ' tests' }
878887OrderedDictionaryTest >> testHash [
879888 | dictionary otherDictionary internalDictionary otherInternalDictionary |
Original file line number Diff line number Diff line change @@ -306,6 +306,16 @@ OrderedDictionary >> errorInvalidIndex: anIndex [
306306 SubscriptOutOfBounds signalFor: anIndex
307307]
308308
309+ { #category : ' enumerating' }
310+ OrderedDictionary >> flatCollect: aBlock [
311+ " Evaluate aBlock for each of the receiver's values (by opposition to keys) and answer the
312+ list of all resulting values flatten one level. Assumes that aBlock returns some kind
313+ of collection for each element. Equivalent to the lisp's mapcan"
314+ " If you want to have keys use associations collect: or associations flatCollect: "
315+
316+ ^ self flatCollect: aBlock as: OrderedCollection
317+ ]
318+
309319{ #category : ' private' }
310320OrderedDictionary >> growOrderedKeys [
311321 orderedKeys :=
You can’t perform that action at this time.
0 commit comments