[MUSIC] Okay, so now let's go into the last topic here. And I have an example of friends or wedding guests that we need to sit at the reception, to learn how to use some of the other methods on the set type. So suppose that we have some friends we're inviting to a wedding. And we want the friends that have someone in common to sit together at the reception. So here I have a few sets of friends, my hometownFriends, toykoFriends, and commonFriends. So let's see how we can determine commonFriends. var hometownFriends is a set which contains Barbara, John, Trina and Justin. And tokyoFriends is a set that contains Justin, Yusuke, Naomi, and Yuya. So Justin is in both sets. And we can see if there's any common friends by just looking, because we created these sets. But in a real application, we might not have been the ones to create the data, so we want to do this in a dynamic fashion. So we would say something like var commonFriends = hometownFriends.intersect(tokyoFriends). This intersect method will tell us all of the values that are the same between those two sets we're comparing. So we see that Justin is indeed in both of those sets. All right, so now we can say var table1Guests is going to be of type a set that accepts string values. And I can say if commonFriends.count is greater than 0, so if there are any friends in common, then table1Guests = hometownFriends.union(tokyoFriends). And I see now I get all of those people from both lists. Excuse me, both sets. I had four values in the first set, and four values in the second set. I would maybe fall into the pitfall of assuming that I would get eight values. But keep in mind that Justin was a duplicate between those two sets, so Justin will only appear once. We will end up with seven values. Okay, let's move on. So planning seating arrangements can be pretty tedious, and we are developers, so let's try to make this easier. Try to create a table of eight people. And if there are no duplicates in a group of four, combine the groups to make a table. So this is kind of trying to ask you to think ahead a little bit. How would you implement a more real-world application, and make this perhaps a little bit more dynamic? So this isn't going to be totally generic, but it is done in a more dynamic fashion. So we could do something like get a very long list, or a long set, of wedding guests and ask our program to maybe try and put those guests together at a table for us, maybe with some set of rules around it. So maybe this rule will go something like, create two sets of four. Make sure there are no duplicates in either group of four. And if there are not, combine them into a table of eight for us. Okay, so I have here var unseatedGuestsOfBride equals a set containing these people. And var unseatedGuestsOfGroom equals another set of people. And I want to initialize some memory for my table2Guests, right? So I'll just say it's going to be a set that accepts some strings, and we'll put some values into it later. But for now let it be nil with this question mark. So I can see if unseatedGuestsOfGroom.isDisjointWith(unse- atedGuestsOfBride), just because that happens to be our two sets that we've declared here. Then I can say table2Guests equals unseatedGuestsOfGroom.union(unseatedGuest- sOfBride). So we look over here and we see 1, 2, 3, 4, 5, 6, 7, 8. Eight values now, whereas we saw seven values in the previous example. Keep in mind that were looking at union of two sets that had one value in common, so that value will not be duplicated when we union them together. In the second example, we're unioning two sets which are totally mutually exclusive. So we'll get all of the values from both sets, since there was no overlap, and end up with eight values. Okay, and lastly just to show you a couple more things that I pointed out on the slides. We can now see how many guests are at table two. Just to confirm that our, well, it's not really a function quite yet. We'll learn about functions in another lesson, but learn to check that our logic worked. Our table2Guests.count is eight, so that's good. That's what we wanted, we wanted to make tables of eight. And lastly, let's say that on the day of the wedding, our wedding planner heard that Katie could not make it. So we can just say table2guest.remove("Katie"). And if Katie was found in the table2Guest's set, then she'll be removed. And so we can say table2guest.count now equals 7. So let's look at what we covered in this sets topic. We learned of course, what is a set. We learned how to create mutable and immutable sets. We learned how to get information about the set itself, such as the number of values inside using the .count property. We talked about the usage of sets versus that of other collection types that we've learned about, such as arrays and dictionaries. We talked about how to compare the values contained in multiple sets, and how do you combine those values together. [MUSIC]