@@ -81,6 +81,29 @@ public protocol RandomAccessCollection :
81
81
/// }
82
82
/// // c == MyFancyCollection([2, 4, 6, 8, 10])
83
83
var indices : Indices { get }
84
+
85
+ /// Accesses a contiguous subrange of the collection's elements.
86
+ ///
87
+ /// The accessed slice uses the same indices for the same elements as the
88
+ /// original collection uses. Always use the slice's `startIndex` property
89
+ /// instead of assuming that its indices start at a particular value.
90
+ ///
91
+ /// This example demonstrates getting a slice of an array of strings, finding
92
+ /// the index of one of the strings in the slice, and then using that index
93
+ /// in the original array.
94
+ ///
95
+ /// let streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"]
96
+ /// let streetsSlice = streets[2 ..< streets.endIndex]
97
+ /// print(streetsSlice)
98
+ /// // Prints "["Channing", "Douglas", "Evarts"]"
99
+ ///
100
+ /// let index = streetsSlice.index(of: "Evarts") // 4
101
+ /// print(streets[index!])
102
+ /// // Prints "Evarts"
103
+ ///
104
+ /// - Parameter bounds: A range of the collection's indices. The bounds of
105
+ /// the range must be valid indices of the collection.
106
+ subscript( bounds: Range < Index > ) -> SubSequence { get }
84
107
}
85
108
86
109
/// Supply the default "slicing" `subscript` for `RandomAccessCollection`
0 commit comments