Published Jan 23, 2023
Contribute to Docs
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:
- Anonymous contributorAnonymous contributor
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Swift on Codecademy
Build iOS Apps with SwiftUILearn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
Includes 7 Courses