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}")
}
}
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
Post a Comment