Delete key-value pair
var bookShelf = [
"Goodnight": "Margaret Wise Brown",
"The BFG": "Roald Dahl",
"Falling Up": "Shel Silverstein",
"No, David!": "David Shannon"
]
// remove value by setting key to nil
bookShelf["The BFG"] = nil
// remove value using .removeValue()
bookShelf. removeValue(forKey: "Goodnight")
// remove all values
bookShelf. removeAll()
Comments