Joining two sets

If you look at the following diagram, you will see the two sets joined together:

Using the union() method, we get a consolidated list of items with no duplicates. Let's try this in Playgrounds:

craigsFavMovieSet.union(gabesFavMovieSet)

Your code should now look like this:

We have a combined list of movies that includes all of the movies that the two sets did not have in common, along with the two movies that were in common but listed only once. As you can see, sets are really powerful, and you can use them to manipulate data. Finally, we need to look at how we can remove items from a set.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.54.199