File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,25 @@ public protocol RangeExpression {
74
74
}
75
75
76
76
extension RangeExpression {
77
+
78
+ /// Returns a Boolean value indicating whether a value is included in a
79
+ /// range.
80
+ ///
81
+ /// You can use the pattern-matching operator (`~=`) to test whether a value
82
+ /// is included in a range. The pattern-matching operator is used
83
+ /// internally in `case` statements for pattern matching. The following
84
+ /// example uses the `~=` operator to test whether an integer is included in
85
+ /// a range of single-digit numbers:
86
+ ///
87
+ /// let chosenNumber = 3
88
+ /// if 0..<10 ~= chosenNumber {
89
+ /// print("\(chosenNumber) is a single digit.")
90
+ /// }
91
+ /// // Prints "3 is a single digit."
92
+ ///
93
+ /// - Parameters:
94
+ /// - pattern: A range.
95
+ /// - bound: A value to match against `pattern`.
77
96
@inlinable
78
97
public static func ~= ( pattern: Self , value: Bound ) -> Bool {
79
98
return pattern. contains ( value)
You can’t perform that action at this time.
0 commit comments