Consider the following code:
rankedGames at: rank ifAbsentPut: [SortedCollection sortBlock: [:one :two | one name < two name]].
I've only seen this "convenience" method used a couple of times in Smalltalk code, and then there is that SortedCollection there with no direct Obj-C equivalent. What is the Objective-C equivalent?
There isn't a direct equivalent.
NSMutableArray
gives you an ordered collection that can be sorted, so that's probably the closest toSortedCollection
. I don't know of a single-line equivalent ofat:ifAbsentPut:
, so you'd normally do that in a few lines: