Operator is


fun main(args: Array) {
var test=15
if (test !is String)

Why I have “Error:(6, 18) Kotlin: Incompatible types: String and Int”?


Because the variable test has type Int. Int is a final type, so it’s known at compilation time that a variable of type Int can never hold a value of any other type, including String, and the is check would never return true. Therefore, such a check doesn’t make sense and is highlighted as an error.

The !is check uses the same rules; in this case it would always return true, so the check still doesn’t make sense.


Ok, I understood


“test is Int” and “test !is Int”, do they make sense?