Reason for precedence of operators with a type on the right-hand side
-
29-04-2021 - |
Question
Kotlin Grammar-Precedence: -
gives the operator precedence table for Kotlin, including the operators with a type on the right-hand side, :
, as
and as?
, which have precedence in between the multiplication and prefix operators.
Is there a reason for giving them that particular precedence? I can't offhand think of a situation where it would be necessary/advantageous; what am I missing?
Solution
We wanted to avoid parentheses in cases where something has to be cast and then added/checked for "in" etc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow