can the <https://kotlinlang.org/docs/reference/gra...
# language-proposals
e
can the https://kotlinlang.org/docs/reference/grammar.html rule for
ifExpression
be changed from
Copy code
'if' '(' expression ')' (controlStructureBody | (controlStructureBody? ';'? 'else' (controlStructureBody | ';')) | ';')
to
Copy code
'if' '(' expression ')' (controlStructureBody | (controlStructureBody? ';'? 'else' (ifExpression | controlStructureBody | ';')) | ';')
or some other equivalent change, to make
Copy code
if (…) { … } else if (…) { … } else { … } ?: …
parse like
Copy code
(if (…) { … } else if (…) { … } else { … }) ?: …
rather than the current unintuitive
Copy code
if (…) { … } else (if (…) { … } else { … } ?: …)
?
d
1. This will be dramatic breaking change, which can change behavior of lots of existing code 2. It's better to use
when
in such cases So no, it can not
e
I realize it's a breaking change and
when
works better (as I recommended in the linked thread), but any existing code relying on this is likely confused
at the very least I believe it should be a warning (which would be the first step to making such a change anyway)
☝️ 7