Skip to content

Commit 8ecf621

Browse files
committed
More conclusions from UX research
1 parent ca66cfe commit 8ecf621

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

proposals/open-ended-ranges.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ the `lastIndex` extension property returning the last index value, namely `size
2121
allowing to instantiate a range of discrete integral values like `0 until size` which is equivalent to `0..(size - 1)`.
2222

2323
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.
2624

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
2831
on par with the `..` operator and make it very clear that the upper bound is not included.
2932

3033
## Use cases
@@ -211,6 +214,16 @@ if they use experimental API in their code.
211214

212215
## Alternatives
213216

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+
214227
### Adapt the existing range interface for open-ended ranges
215228

216229
Instead of introducing a new interface for open-ended ranges, reuse the existing range interface and

0 commit comments

Comments
 (0)