Skip to content

Commit

Permalink
Add a section about equality
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-g committed Feb 5, 2024
1 parent 5d3d49f commit ca66cfe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions proposals/open-ended-ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ operator fun Double.rangeUntil(that: Double): OpenEndRange<Double>
operator fun Float.rangeUntil(that: Float): OpenEndRange<Float>
```

### Equality of open-ended ranges

Similar to closed ranges, the `OpenEndRange` interface does not specify contract for `equals`/`hashCode` implementations,
however its concrete implementations can do that. For example, an open-ended range of double values equal to another such range
when bounds are respectively equal to each other, or to any empty range of doubles, when it is empty itself.

Also, as a consequence of implementing both `OpenEndRange` and `ClosedRange` in concrete range implementations for standard discrete types,
an open-ended range is equal to the closed range with the same `start` value and `endExclusive` equal to `endInclusive + 1`:
```kotlin
0..<10 == 0..9 // true
```

## Experimental status

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

0 comments on commit ca66cfe

Please sign in to comment.