[SOLVED} Different ranges of `LocalTime` (or `Loca...
# kotlinx-datetime
r
[SOLVED} Different ranges of
LocalTime
(or
LocalDateTime
or even
Instant
) are comparing as
true
? Huh?
Copy code
val a = LocalTime(21, 0)..LocalTime(9, 0)
val b = LocalTime(22, 0)..LocalTime(9, 15)

// true ??
println(a == b)
Actually, seems this is not a kotlinx-datetime question:
Copy code
val a = 5..1
val b = 6..1

// true
println(a == b)
I guess in one way I can see this, as no value can fall between start and end, therefore the ranges are in effect empty and equal. But its still a bit surprising. Especially when one looks at the implementation of
ComparableRange.equals
, its checking equality of
start
and
endInclusive
, which would cause that equality to be false.
Ah yes, there is a check there for
isEmpty
. Ok!
rubber duck 3