Reputation: 3971
I'm trying to map a dictionary to a flattened array of its values. Turn this object into [Object]
var objectsDic: [Int : [[Object]]]
I finally found a way that works
objectsDic.map { $0.value }.flatMap { $0 }.flatMap { $0 }
Is there a better way to do this without using two separate flat map calls? Thanks!
Upvotes: 4
Views: 1226
Reputation: 13679
A hybrid of some of the suggestions in the comments, and I believe the most concise notation:
objectsDict.flatMap{$0.value.joined()}
Upvotes: 3