Sergio C.
12/29/2021, 12:49 PM!is
how can we create an extension or infix function for !is to use it like`someVar isnot String`?Dominaezzz
12/29/2021, 12:54 PMString cannot be passed as a value. Unless you're okay with someVar isnot String::class ?Sergio C.
12/29/2021, 12:57 PMDominaezzz
12/29/2021, 12:58 PMpublic inline infix fun <reified T : Any> Any?.isnot(ignored: KClass<T>): Boolean {
return this !is T
}
public fun test() {
val lol: Any = "Some stuff"
if (lol isnot String::class) {
println("Yay!")
}
}Sergio C.
12/29/2021, 12:59 PMSergio C.
12/29/2021, 12:59 PMSergio C.
12/29/2021, 12:59 PMDominaezzz
12/29/2021, 1:01 PM