It is time to make an instance of Set. Create a new playground called Groceries.
Type in the following to get an instance of Set.
Listing 11.1 Creating a set
var str = "Hello, playground"var groceryBag = Set<String>()
You made an instance of Set and declared that it will hold instances of the String type. It is a mutable Set called groceryBag and is currently empty. Let’s fix that.
You can add groceries to your groceryBag using the insert(_:) method.
Listing 11.2 Adding to a set
... var groceryBag = Set<String>() groceryBag.insert("Apples") groceryBag.insert("Oranges") groceryBag.insert("Pineapple")
You may notice that the results sidebar shows something like
(.0 true, .1 "Apples") ...