i have a generic class and want to define an inner...
# announcements
i have a generic class and want to define an inner interface to define a handler for that type (which would include the generic). i.e.:
Copy code
class Foo<T> {
   inner interface FooEventHandler {
     fun event(value: T)
but it looks like this isn't possible (it says
can't be used with
). is there a good way to accomplish something like this? i don't want the user to have to define the generic type in 2 places (once for Foo and once for instantiating a FooEventHandler, because it could only lead to a mistake)
on top of that, i think implementing the interface would be impossible (`object : myFoo.FooEventHandler`doesn't work i don't think) so just wondering if there's another good strategy for this sort of thing
inner class
means instances of the class always store a reference to the base class, and of course that isn't possible with interfaces. You'll have to repeat the generic argument.
makes sense, thanks @karelpeeters