Posted on 2nd July 2025|40 views
How can we check the class instance of in kotlin?
Posted on 2nd July 2025| views
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)
}