contains(_:)
Returns a Boolean value indicating whether the given closed range is contained within this range.
Declaration
func contains(_ other: ClosedRange<Bound>) -> BoolParameters
- other:
A closed range to check for containment within this range.
Return Value
true if other is wholly contained within this range; otherwise, false.
Discussion
The given closed range is contained within this range if its bounds are contained within this range. If this range is empty, it cannot contain a closed range, since closed ranges by definition contain their boundaries.
let range = 0..<10
range.contains(2...5) // true
range.contains(2...10) // false
range.contains(2...12) // false
let emptyRange = 3..<3
emptyRange.contains(3...3) // false