is there a way to write `foobar` so that I can pas...
# announcements
k
is there a way to write
foobar
so that I can pass ::class of either subclasses? https://pl.kotl.in/Y5NcoKR3K
r
Neither
Boy
nor
Girl
subclass
Parent
in your example.
t
Don’t know if I understood you correctly, but might be what you are searching for
k
forgot to make Boy/Girl subclasses of Parent in the example 🙂 in real code they are...
yup, I was missing the
out
modifier!
so that would mean that KClasses of A and B are in a subtyping relationship if A and B are in a subtyping relationship?
t
I don’t think so. KClasses are not in a relationship. The generic is, so you are just telling the type system, that everything which comes in, must be at least of type person. But this doesn’t really create a relationship for the class object, as both are from type ‘KClass’ and only their generic type is from ‘A’ or ‘B’
Probably doesn’t make sense 🤦‍♂️
k
it kind of does! and it seems to work 😉
👍 1