removeSubranges(_:)
Removes the elements at the given indices.
Declaration
mutating func removeSubranges(_ subranges: RangeSet<Self.Index>)Parameters
- subranges:
The indices of the elements to remove.
Discussion
For example, this code sample finds the indices of all the vowel characters in the string, and then removes those characters.
var str = "The rain in Spain stays mainly in the plain."
let vowels: Set<Character> = ["a", "e", "i", "o", "u"]
let vowelIndices = str.indices(where: { vowels.contains($0) })
str.removeSubranges(vowelIndices)
// str == "Th rn n Spn stys mnly n th pln."