Skip to content

Commit d0f37ac

Browse files
committed
Expand summary of the Swift range API
1 parent 8ecf621 commit d0f37ac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

proposals/open-ended-ranges.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ println(eqivalent) // 1..1.9999999999999998
7979
However, the base [Range](https://docs.groovy-lang.org/latest/html/api/groovy/lang/Range.html) interface doesn't indicate inclusiveness and
8080
has somewhat contradictory contract of `containsWithinBounds` function.
8181

82-
- Swift distinguishes open-ended [`Range`](https://developer.apple.com/documentation/swift/range) and closed [`ClosedRange`](https://developer.apple.com/documentation/swift/closedrange)
83-
structures.
82+
- Swift has the base protocol [`RangeExpression`](https://developer.apple.com/documentation/swift/rangeexpression/) which is implemented
83+
by the open-ended [`Range`](https://developer.apple.com/documentation/swift/range),
84+
the closed [`ClosedRange`](https://developer.apple.com/documentation/swift/closedrange),
85+
and also the one-sided `PartialRangeFrom` (start-inclusive), `PartialRangeThrough` (end-inclusive), `PartialRangeUpTo` (end-exclusive) ranges.
86+
The base protocol provides operations of checking whether the range contains a value and slicing a collection
87+
(i.e. producing the closed range of indices of the collection with the matching index type that are contained in the range).
8488

8589
- [kotlin-statistics](https://github.com/thomasnield/kotlin-statistics/blob/master/src/main/kotlin/org/nield/kotlinstatistics/range)
8690
library provides the base `Range` type and individual types for each combination of included/excluded bounds:

0 commit comments

Comments
 (0)