Should/will the error be removed in future Kotlin ...
# android
a
Should/will the error be removed in future Kotlin versions when using
.not()
?
v
Variable val name is type “String?” and the argument name in requireName is type “String”. Change the argument name to type “String?” in the function requireName and code will be work.
a
I don’t want a nullable value in the function, sorry I meant
requireName()
can be any function
v
if you do not want a nullable value just use
requireName(name!!)
. Not the best...but it's going to work as you want
t
The question here is that
isNullOrEmpty
uses Kotlin Contracts and should be able to smart cast to
String
when returning false. This does not work when calling
condition.not()
which is equivalent to
!condition
.
👆 1
👌 1