Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
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 :