Instance Method

contains(_:)

Returns a Boolean value indicating whether the given element is contained within the range.

Declaration

func contains(_ element: Bound) -> Bool

Parameters

element

The element to check for containment.

Return Value

true if element is contained in the range; otherwise, false.

Discussion

Because Range represents a half-open range, a Range instance does not contain its upper bound. element is contained in the range if it is greater than or equal to the lower bound and less than the upper bound.

Relationships

From Protocol

See Also

Checking for Containment

func contains(where: (Bound) -> Bool) -> Bool

Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.

func allSatisfy((Bound) -> Bool) -> Bool

Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.

static func ~= (Range<Bound>, Bound) -> Bool

Returns a Boolean value indicating whether a value is included in a range.