bob
03/31/2017, 10:38 PMtrue
or false
.. not null.
So in a way there's less sense in having a Boolean?
type at all.
And if we compare with java the primitive boolean
has false
as default value. As per say if it’s not explicitly sat to true
it is in fact false
.
But I see where you’re coming from and I understand, I was just hoping that something that is used often might be in consideration some syntactic sugaring to get rid of verboseness.groostav
04/01/2017, 6:55 AMBoolean?
might get you somewheregroostav
04/01/2017, 6:55 AMval Boolean?.falseIfNull: Boolean get() = this ?: false
object Thingy {
fun isDisposed(): Boolean = TODO()
}
fun test(){
val sth: Thingy? = Thingy
if(sth?.isDisposed().falseIfNull){
//...
}
}
groostav
04/01/2017, 7:00 AMgroostav
04/01/2017, 7:02 AMoperator fun Boolean?.unaryPlus(): Boolean = this ?: false
object Thingy {
fun isDisposed(): Boolean = TODO()
}
fun test(){
val sth: Thingy? = Thingy
if(+sth?.isDisposed()){
//...
}
}