Skip to content

Commit ca66cfe

Browse files
committed
Add a section about equality
1 parent 5d3d49f commit ca66cfe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

proposals/open-ended-ranges.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ operator fun Double.rangeUntil(that: Double): OpenEndRange<Double>
181181
operator fun Float.rangeUntil(that: Float): OpenEndRange<Float>
182182
```
183183

184+
### Equality of open-ended ranges
185+
186+
Similar to closed ranges, the `OpenEndRange` interface does not specify contract for `equals`/`hashCode` implementations,
187+
however its concrete implementations can do that. For example, an open-ended range of double values equal to another such range
188+
when bounds are respectively equal to each other, or to any empty range of doubles, when it is empty itself.
189+
190+
Also, as a consequence of implementing both `OpenEndRange` and `ClosedRange` in concrete range implementations for standard discrete types,
191+
an open-ended range is equal to the closed range with the same `start` value and `endExclusive` equal to `endInclusive + 1`:
192+
```kotlin
193+
0..<10 == 0..9 // true
194+
```
195+
184196
## Experimental status
185197

186198
Both the language feature of `rangeUntil` operator and its supporting standard library API

0 commit comments

Comments
 (0)