https://kotlinlang.org logo
Title
r

reline

09/18/2017, 1:34 PM
hey guys, I'm having a problem here where when
myString == null
it matches both the
String?
and
Int?
types. Anyone know a way around this?
fun hello(myString: String?, myBoolean: Boolean) {}

fun hello(myInt: Int?, myBoolean: Boolean) {}

fun hi(myString: String?) {
    if (myString == null) {
        hello(myString, false) //overload resolution ambiguity
    } else {
        hello(myString, true) // this works fine
    }
}
m

marstran

09/18/2017, 1:36 PM
Calling
hello
with either
null as Int?
or
null as String?
should resolve the ambiguity.
r

reline

09/18/2017, 1:37 PM
that works, thanks!