I want to write something like that in Kotlin.
open class View<P> where P:Presenter<out _this_class_> {
val presenter: P = ...
}
open class Presenter<V> where V: View<out _this_class_> {
val view: V = ...
}
How I can properly do that?
The standard way (called F-bounded polymorphism) is
open class View<V: View<V, P>, P: Presenter<out V>> { ... }
It may make more sense to put out
elsewhere here, depending on the specifics:
open class View<out V: View<V, P>, out P: Presenter<V>> { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With