Contents

==(_:_:)

Returns a Boolean value indicating whether two ranges are equal.

Declaration

static func == (lhs: Range<Bound>, rhs: Range<Bound>) -> Bool

Parameters

  • lhs:

    A range to compare.

  • rhs:

    Another range to compare.

Discussion

Two ranges are equal when they have the same lower and upper bounds. That requirement holds even for empty ranges.

let x = 5..<15
print(x == 5..<15)
// Prints "true"

let y = 5..<5
print(y == 15..<15)
// Prints "false"

See Also

Comparing Ranges