To remove a key-value pair from a Swift Dictionary (which is essentially a map), you can simply call the removeValue(forKey:)
method while passing the key for the particular entry that you want to remove. Here's an example:
main.swift137 chars4 lines
In the above example, we have a map named myMap
with three entries. We then call the removeValue(forKey:)
method while passing the "banana" key, which removes that particular entry from the map. Finally, we print out the resulting map without the "banana" key-value pair.
gistlibby LogSnag