Smart casting operator "is" and "!is" in kotlin

 


fun main(args: Array<String>) {
/* Smart Cast
for nullable types
is - !is - operator
*/

val obj: Any = 10
if(obj !is Long)
{
println("Obj is not string")
}
else
{
println("Obj is Long ${obj}")
}




}

Comments

Popular posts from this blog

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2.1. Cannot sync the project.

SonarQube With Angular 19 on Windows: A Complete Setup and Integration Guide

Error in Android Migration Gradle 7.5 to 8.5 - java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null