Skip to content

Commit 610d07e

Browse files
authoredJan 16, 2025
[stdlib] Fix doc comment refs to subranges(where:), now called indices(where:) (#78512)
Doc comments for DiscontiguousSlice, MutableCollection, RangeSet, and RangeReplaceableCollection all refer to a Collection method subranges(where:) which is intended to return a RangeSet of matching ranges. I believe this is likely an old or formerly-contemplated spelling of the method now known as indices(where:). This commit changes "subranges" to "indices".
1 parent 452302e commit 610d07e

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed
 

‎stdlib/public/core/DiscontiguousSlice.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ extension Collection {
393393
///
394394
/// let str = "The rain in Spain stays mainly in the plain."
395395
/// let vowels: Set<Character> = ["a", "e", "i", "o", "u"]
396-
/// let vowelIndices = str.subranges(where: { vowels.contains($0) })
396+
/// let vowelIndices = str.indices(where: { vowels.contains($0) })
397397
///
398398
/// let disemvoweled = str.removingSubranges(vowelIndices)
399399
/// print(String(disemvoweled))

‎stdlib/public/core/MutableCollection.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ extension MutableCollection {
377377
/// moves them to between `"i"` and `"j"`.
378378
///
379379
/// var letters = Array("ABCdeFGhijkLMNOp")
380-
/// let uppercaseRanges = letters.subranges(where: { $0.isUppercase })
380+
/// let uppercaseRanges = letters.indices(where: { $0.isUppercase })
381381
/// let rangeOfUppercase = letters.moveSubranges(uppercaseRanges, to: 10)
382382
/// // String(letters) == "dehiABCFGLMNOjkp"
383383
/// // rangeOfUppercase == 4..<13

‎stdlib/public/core/RangeReplaceableCollection.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ extension RangeReplaceableCollection {
11851185
///
11861186
/// var str = "The rain in Spain stays mainly in the plain."
11871187
/// let vowels: Set<Character> = ["a", "e", "i", "o", "u"]
1188-
/// let vowelIndices = str.subranges(where: { vowels.contains($0) })
1188+
/// let vowelIndices = str.indices(where: { vowels.contains($0) })
11891189
///
11901190
/// str.removeSubranges(vowelIndices)
11911191
/// // str == "Th rn n Spn stys mnly n th pln."
@@ -1216,7 +1216,7 @@ extension MutableCollection where Self: RangeReplaceableCollection {
12161216
/// numbers in the array, and then removes those values.
12171217
///
12181218
/// var numbers = [5, 7, -3, -8, 11, 2, -1, 6]
1219-
/// let negativeIndices = numbers.subranges(where: { $0 < 0 })
1219+
/// let negativeIndices = numbers.indices(where: { $0 < 0 })
12201220
///
12211221
/// numbers.removeSubranges(negativeIndices)
12221222
/// // numbers == [5, 7, 11, 2, 6]

‎stdlib/public/core/RangeSet.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/// locations of all the negative values in `numbers`:
2222
///
2323
/// var numbers = [10, 12, -5, 14, -3, -9, 15]
24-
/// let negativeSubranges = numbers.subranges(where: { $0 < 0 })
24+
/// let negativeSubranges = numbers.indices(where: { $0 < 0 })
2525
/// // numbers[negativeSubranges].count == 3
2626
///
2727
/// numbers.moveSubranges(negativeSubranges, to: 0)

0 commit comments

Comments
 (0)