I’m trying to compare if 2 classes are of the same...
# announcements
m
I’m trying to compare if 2 classes are of the same instance type but i’m getting an error because
this.contentFragment
is nullable, but i can just null check it
Copy code
var contentFragment: Fragment? = null

fun exec(contentFragment: Fragment) {
  if (contentFragment::class == this.contentFragment?::class) return
}
😱 3
k
maplonki: what do you mean by 2 classes of the same instance? Do you mean 2 instances of the same class? You could replace
::class
with
.javaClass
l
Not sure naming a parameter and a member property the same is a good practice 🤔
👍 2
m
comparing instances is not done that way. you are only comparing if the class is the same
m
@kingsley yeah i meant, 2 instances of the same class, my bad, thanks for pointing that out 🙂