Why does setting a nullable type to null result in an "Overload resolution ambiguity"?

22 views Asked by At

Not Understanding The Null Error Here In KOTLIN

 var adam :String? = "i love MY cat"
    adam = null
    print(adam?.uppercase())

**So im getting an error at the

.uppercase() 

and its saying

** `<html>Overload resolution ambiguity:<br/>public inline fun Char.uppercase(): String defined in kotlin.text<br/>public inline fun String.uppercase(): String defined in kotlin.text ,` 

and if i remove the ? from print(adam?.uppercase()) its giving me this

<html>None of the following function`your text`s can be called with the arguments supplied:<br/>public inline fun Char.uppercase(): String defined in kotlin.text<br/>public inline fun String.uppercase(): String defined in kotlin.text

So I'm kinda confused because I'm declaring the var as a nullable String so why is it Giving An Error when I'm saying its null?

0

There are 0 answers