Suggested approach: Remember to give practical examples as well as outlining the core differences. So, you might start by saying the
map() transforms a sequence using a function we specify, whereas
compactMap() does that same step but then unwraps its optionals and discards any nil values. For example, converting an array of strings into integers works better with
compactMap(), because creating an
Int from a
String is failable.
Estimated difficulty: Easy
UUID, and when might you use it?
Link copied to your pasteboard.