@@ -18,7 +18,7 @@ and ending one before the number of elements in it, so to iterate these indices,
18
18
For such a common use case, Kotlin standard library provides various shortcut functions, such as
19
19
the ` indices ` extension property available on many data structures returning that ` 0..(size - 1) ` range,
20
20
the ` lastIndex ` extension property returning the last index value, namely ` size - 1 ` , and finally the ` until ` infix function
21
- allowing to instantiate a range of discrete integral values like ` 0 until size ` which is equivalent to ` 0..(size - 1) ` .
21
+ allowing to instantiate a range of integral values like ` 0 until size ` which is equivalent to ` 0..(size - 1) ` .
22
22
23
23
Despite all of this, due to asymmetry between ` .. ` and ` until ` , the former is used more often, even in cases where the latter would be more clear.
24
24
@@ -34,7 +34,8 @@ on par with the `..` operator and make it very clear that the upper bound is not
34
34
35
35
Currently, the use cases of the new operator are mostly covered by the ` until ` function, that corrects the upper bound
36
36
returning a closed range of integral values that would be equivalent to an open-ended range.
37
- However, the ` until ` function is available only for integral or discrete argument types, such as ` Int ` , ` Long ` , ` Char ` ,
37
+ However, the ` until ` function is available only for the types where finding the successor to a value is done by adding 1 to that value,
38
+ such as ` Int ` , ` Long ` , ` Char ` ,
38
39
and having the new operator gives a chance for introducing open-ended ranges for those type that didn't have it before.
39
40
40
41
### Iterating indices of a data structure
@@ -50,7 +51,7 @@ Such intervals are usually chosen as ranges that include their lower bound and e
50
51
adjacent ranges neither have a point where they overlap, nor a point between them that is not contained in these ranges.
51
52
52
53
Even sometimes when the value is already discrete, for example, when it is expressed as a ` Double ` number,
53
- and it is possible to represent a half-open range with a closed one by adjusting one of its bounds,
54
+ and it is possible to emulate a half-open range with a closed one by adjusting one of its bounds,
54
55
in practice it is not convenient to work with such ranges:
55
56
56
57
``` kotlin
@@ -204,8 +205,9 @@ Similar to closed ranges, the `OpenEndRange` interface does not specify contract
204
205
however its concrete implementations can do that. For example, an open-ended range of double values equal to another such range
205
206
when bounds are respectively equal to each other, or to any empty range of doubles, when it is empty itself.
206
207
207
- Also, as a consequence of implementing both ` OpenEndRange ` and ` ClosedRange ` in concrete range implementations for standard discrete types,
208
- an open-ended range is equal to the closed range with the same ` start ` value and ` endExclusive ` equal to ` endInclusive + 1 ` :
208
+ Also, as a consequence of implementing both ` OpenEndRange ` and ` ClosedRange `
209
+ in concrete range types for the standard integral types and ` Char ` type,
210
+ in these range types an open-ended range is equal to the closed range with the same ` start ` value and ` endExclusive ` equal to ` endInclusive + 1 ` :
209
211
``` kotlin
210
212
0 .. < 10 == 0 .. 9 // true
211
213
```
0 commit comments