Does Listing 25.10 show an incorrect result?

“Listing 25.10 Ranges of comparable types

let cLessThanEqualD = (c <= d) true
let cGreaterThanD = (c > d) false
let cGreaterThanEqualD = (c >= d) false

let pointRange = c…<d {{x 2, y 6, nil},…
pointRange.contains(a) true
pointRange.contains(Point(x: -1, y: -1)) false”

I believe I’ve carefully reproduced the statements in the playground. But with Swift 5.7, pointRange.contains(a) evaluates to false when the code runs.

Has the playground been tested with Swift 5.7?

I figured it out by adding the following to my playground (points and pointRange as defined in the playground):

pointRange.lowerBound.x < a.x
true
pointRange.upperBound.x > a.x
false
pointRange.upperBound.x == a.x
true

pointRange is defined as a half-open interval. The x-value of the upper bound is the same as a.x. The upper bound is not greater than a.x. Thus a is not contained in the range.