So I had another thought yesterday. lol. on this s...
# language-proposals
s
So I had another thought yesterday. lol. on this super elvis operator. The example I gave isn't really where it would be able to shine, if this was implemented to catch any null within an expression and propagate it through that operator. In this case, it is syntactic sugar for catching null reference exceptions more elegantly. An example I thought about is when you are calling a java method via kotlin and there is a null being thrown inside somewhere, then that operator will take care of it. So rather than ?: checking the null at the end of an expression, ??: will check any null within an expression. So in a sense it is a wrapper. In that case, it wouldn't have to change any behavior of
.
@dalexander
👎🏼 2
k
Not really sure why this is so much better than the null coalescing operator. In the best case, it saves a few keystrokes, but not without a price. Mind you, the ??: coming at the end makes for a weird intuition (for me at least), since the expression coming before that operator might very well be a compile time error, and the IDE won’t be able to discern if this will eventually be “super elvised” or not