Claiming koltin is so concise, wouldn’t an `if?`st...
# language-proposals
b
Claiming koltin is so concise, wouldn’t an `if?`statement qualify. So that one can write
if?(state?.isValid)
instead of
if(state?.isValid == true)
So when we have an if-statement of an nullable value we don’t have to explicitly declare the
== true
all the time.
7
g
?
is null safety operator, it’s not clear how
if?
should work. I think it’s too implicit and dirty syntax imho. Also, what if I want to have
if(state?.isValid == false)
condition?
👍 2
a
if?!(state?.isVaild)
🧌
😬 2
😆 3
b
Good point Andrey.. didn’t think of the negation since I tend to never write code that way since it’s not as clear to read. But it’s a good point for general language feature. Just so tired of writing explicit `== true`…
g
you can write extension property for particular usage
val StateHolder.isValidState get() = state?.isValid == true