0

How can we check the class instance of in kotlin?

Jun 16, 2020 in Kotlin by Jordan

1 answers to this question.

0

Class "instance of" can be checked by using the keyword is or !is

A simple example is given below: 

if(myInstance is string)

{

print(string)

}

if(myInstance !is string)

{

print(not a string)

}

else

{

print(null)

}

Jun 16, 2020 answered by Harshel

Related Questions

0 1 answers

Kotlin Lambda Example

Explain about kotlin lambda expression with example?

Jun 16, 2020 in Kotlin by Irshad
0 1 answers

Kotlin Abstract Class

What is the abstract class in kotlin?

Jun 16, 2020 in Kotlin by Irshad
0 1 answers

Kotlin Default Arguments

How the default argument in kotlin works?

Jun 16, 2020 in Kotlin by Irshad