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 negative numbers in the array, and then removes those values.
var numbers = [5, 7, -3, -8, 11, 2, -1, 6]
let negativeIndices = numbers.indices(where: { $0 < 0 })
numbers.removeSubranges(negativeIndices)
// numbers == [5, 7, 11, 2, 6]