Checking whether a set contains an item

The first thing we can do with sets is check whether a set includes an item. Let's see whether Craig's movie list includes the movie Green Mile:

if craigsFavMovieSet.contains("Green Mile") { 
  print("Green Mile found") 
} 

Your code should now look like this:

In the preceding example, we used the contains() method to discover whether an item is in the set.

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

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