Chapter 3
Collection and Range
Section 2
Compact Map Values
Prior to Swift 5, when working with a dictionary, we could use the mapValues function to process the values in a collection, by passing a closure into the function. However, any nil values will also be added to the result, which will then have to be filtered out in another operation. Swift 5 improved on mapValues function with the introduction of compactMapValues, which provide much more compact results.