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

SwiftUI - Tutorial 2 - 🧵 Understanding @MainActor in SwiftUI — A Beginner’s Guide

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

Setting Up Jenkins for Flutter App on macOS