Welcome to the Treehouse Community
Looking to learn something new?
Trevor Duersch9,964 Points
Is flatMap deprecated?
Is flatMap depcreated? I am currently in the video on closures and reviewing the "Flat Map" video - https://teamtreehouse.com/library/flat-map . I got a warning saying that flatMap was deprecated and I should use compactMap. Once I changed the code from "flatMap" to "compactMap", the functionality was still there and the warning went away.
Caleb KleveterTreehouse Moderator 37,862 Points
Correct. In essence,
flatMap was just renamed to
compactMap because it makes more sense. From this method, you only get the non-nil results of the closure passed in.
nil is left out of the resulting array.
@Caleb : not really the same result, it doesn't flatten the array of array to an array. In the video example, the type of tags is :