Jan. 5, 2013
5:06 a.m.
Is there a more elegant way to increment the value of a dictionary entry than what I have done in "this line" below? elements := #( 1 1 2 2 2 2 3 3 3 3 3 3) asOrderedCollection. elementCounter := Dictionary new. elements do: [ :key | elementCounter at: key put: (elementCounter at: key ifAbsent: [ 0 ]) + 1 ]. "this line" elementCounter inspect. "--> a Dictionary(1->2 2->4 3->6 )" cheers -ben