https://kotlinlang.org logo
c

cedric

03/25/2018, 10:30 AM
@kingsley I don't understand your point with the snippet of code above. Considering
null
as
false
is pretty intuitive. Kotlin by design avoids implicit conversions as much as possible, which is why that code is invalid but I don't think it would lead to bugs or hard to read code to silently convert a
null
Boolean
to
false
k

kingsley

03/25/2018, 10:37 AM
True, I don’t consider this an everyday use case. But there’s still the distinction between
null
and
false
, and I’d rather avoid any implicit conversion between them. In fact, I’d imagine someone using a nullable boolean probably wanted that distinction in the first place
c

cedric

03/25/2018, 10:39 AM
Nothing stops you from comparing against
null
or
false
explicitly if the distinction matters to your code.
k

kingsley

03/25/2018, 10:45 AM
My point however is that, someone who doesn’t care about the nullability would be better off with a
Boolean
and avoid any unnecessary implicits with the type system. A
Boolean?
on the other hand should force a distinction between
null
and
false
2 Views