what is the most performant way to access erased t...
# getting-started
h
what is the most performant way to access erased types? here's an example where perhaps you want to access it:
Copy code
iterface Foo : Comparable<Bar> {
    override fun equals(other: Any?) = when (other) {
        is Comparable<*> -> // other is Comparable<Bar> && (other as Comparable<Bar>).compareTo(this) == 0
        else -> false
    }
}
cast as and try/catch?
d
is Foo
? 😛
k
Measure it for your distribution types (ideally using JMH)! Things like this are really finicky depending on the number of possible classes that reach that code.
Also, I get the feeling you're setting yourself up for a broken
equals
implementation there.
☝🏼 1
h
yeah, i just wanted to create an example
@Dominaezzz assume
Foo
isn't the only thing implementing
Comparable<Bar>
d
Hmm, without directly asking the subclass for this information (using an extra virtual field), I don't think this is possible.