l
Untitled.kt
s
Please read the channel purpose
Your questions are just fine for #general
l
there, i fixed it. happy now?
r
Cosmetically, I'd prefer
x ?- 7
l
that's just code style
r
Not necessarily.
x ?: 7
is valid.
x? : 7
is not.
l
oh you're right, i forgot about that
but keep in mind that your proposal would introduce a new operator, whereas mine doesn't since
-
is just an infix function that directly translates to
.minus()
(which is why i'm wondering why it doesnt work already)
d
It doesn't have to introduce a new operator? You can write
x ? .minus(...)
as well
I don't really like the idea though. Null pointer exceptions happen when you dot-qualify null. Therefore, the dot qualified expression is integral to the ?. notation to convey the intention. With arithmetic operators, the intention is not clear from the syntax at all.
d
I agree that the operator syntax should be reserved for non-null values,
x?.minus(7)
reads just fine and
x?-7
will require a double-take no matter where the spaces go