Type Checks and Smart Casts in Kotlin: Using `is`, `!is`, and `as` Operators

Type Checks with is and !is Use the is operator to verify if an object matches a specific type at runtime. The negation !is checks if an object does not belong to a type. val inputObj: Any = "Hello Kotlin" if (inputObj is String) { println("String length: ${inputObj.length}") } if (inputObj !is String) { // Equivalent ...

Posted on Wed, 17 Jun 2026 18:08:28 +0000 by footbagger