The .removeAll() method is used to remove every value from a Set in Swift.
.removeAll()will remove all values from
- It is not possible to use a
(where:)condition on a set because
Setdoes not currently conform to the
RangeReplaceableCollectionprotocol that includes that method.
The following is an example of the
var weather: Set = ["spring", "summer", "autumn", "fall", "winter"]weather.removeAll()print(weather)
This will output:
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
- Anonymous contributor
Learn Swift on Codecademy
- Anonymous contributorAnonymous contributor