Issue
In kotlin class, I have method parameter as object (See kotlin doc here ) for class type T. As object I am passing different classes when I am calling method.
In Java we can able to compare class using instanceof
of object which class it is.
So I want to check and compare at runtime which Class it is?
How can I check instanceof
class in kotlin?
Solution
Use is
.
if (myInstance is String) { ... }
or the reverse !is
if (myInstance !is String) { ... }
Answered By - nhaarman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.