But that doesn't work for variables and for classe...
# announcements
k
But that doesn't work for variables and for classes it exposes the generic parameter which I don't really want.
p
What about making a third interface that extends the first 2 ?
k
Problem is implmentors of classes
A
and
B
might not be aware that
C
exists.
That's the solution I'm using now, I'm hoping there's something better.
p
How do you initialize this variable? Usually variable type can be inferred, so you don’t think about such things.
k
It would be set by a function that does use the generics trick.
p
kotlin doesn’t have intersection types. I think the limitations are the same as for java, where the generics trick also works.
k
Okay, just wanted to check. A possible solution is to just have two fields, one for each type.