Is it just me, or is IntelliJ displaying "less tha...
# intellij
Is it just me, or is IntelliJ displaying "less than or equal to" for both sides of a range? I'm pretty sure the left side is meant to be "greater than or equal to".
IntelliJ is correct and the equivalent code is
1 <= score && score <= 4
Fair enough. I suppose it's the difference between "correct" and intuitive.
For what it's worth, the generated code actually seems to be
1 <= score && 4 >= score
, so while
may be technically correct, I think
would be more visually intuitive. 😅
Copy code
if (1 <= score) {
    if (4 >= score) {
        var10000 = Severity.LOW;
        return var10000;
How would you inlay it though?
1 <= .. 4 >=
looks way worse imo
Since the inlay is on the right and left side respectively, you could do
1 >= .. <= 4
or even make both inlays on the left side
>= 1 .. <= 4
. The way that it currently reads (to me) is:
Copy code
score is less than or equal to 1 OR score is less than or equal to 4.
Perhaps it's just me, but I think it's awkward for two reasons. 1. The current inlay implies that ".." is a placeholder for
, but
1 <= score <= 4
isn't generally how you'd express that logic in Kotlin so it isn't as intuitive as seeing it in something like Python. 2. Thinking about the underlying logic in this way slightly defeats the abstraction of range expressions.
score in 1..4
means "is score between a range starting with 1 and ending with 4", but with the inlays it reads as something like "is score in a range starting with less than or equal to 1 and less than or equal to 4". I'm a fan of using inlays to clarify whether "between" is inclusive or exclusive. I just think it be further improved. 🙂
There was a survey where people where asked regarding the visualization, this is what made sense to most in that survey. Not everyone can be pleased I'm afraid.
👍 1
I cannot find the results, but I still have the URL in my history (obviously useless now).
for me it's both correct and intuitive
it's something between
Fair enough — I find it distracting and out of place. At least it's possible to disable the inlay hint.