Dictionary Data Line Swift Flat Map

I am trying to map a dictionary to a flat array of its values. Rotate this object to[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 card calls? Thank!

+4
source share
1 answer

A hybrid of some sentences in the comments, and I consider the most concise notation:

objectsDict.flatMap{$0.value.joined()}
+1
source

Source: https://habr.com/ru/post/1661107/


All Articles