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.

Google Assistant Implementation in Android application with app actions