@@ -21,10 +21,13 @@ the `lastIndex` extension property returning the last index value, namely `size
21
21
allowing to instantiate a range of discrete 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
- Also, our UX research shows that Kotlin newcomers have troubles remembering whether the upper bound of the range produced by ` until `
25
- is exclusive or inclusive.
26
24
27
- To mitigate that, we propose to introduce the operator ` ..< ` in Kotlin that would be
25
+ We have conducted a UX research that showed that Kotlin users may experience troubles identifying whether the ranges created with
26
+ the ` .. ` operator and ` until ` function have their upper bound excluded or included. We also evaluated how introducing new operators
27
+ for range expressions may improve this situation, and it turned out that the effect of that can be significant:
28
+ the misinterpretation rate was less by ~ 20-30% with them.
29
+
30
+ For the above reason, we propose to introduce the operator ` ..< ` in Kotlin that would be
28
31
on par with the ` .. ` operator and make it very clear that the upper bound is not included.
29
32
30
33
## Use cases
@@ -211,6 +214,16 @@ if they use experimental API in their code.
211
214
212
215
## Alternatives
213
216
217
+ ### Introduce the operator ` ..= ` as an alias to ` .. `
218
+
219
+ When conducting the UX research, we have also evaluated what effect the operator ` ..= `
220
+ which basically means the same as ` .. ` could bring.
221
+
222
+ While it has shown that ` ..= ` operator similarly to ` ..< ` reduces the number of errors in interpretation of range expressions,
223
+ the effect of that doesn't overweight negative effects of redundancy brought to the language by having both ` .. ` and ` ..= ` doing the same
224
+ and migration effort required to change ` .. ` to ` ..= ` in Kotlin code bases.
225
+
226
+
214
227
### Adapt the existing range interface for open-ended ranges
215
228
216
229
Instead of introducing a new interface for open-ended ranges, reuse the existing range interface and
0 commit comments