Kotlin class with generics and implementing interfcae

147 views Asked by At

I'm using Kotlin in Android development and I would like to create class with two generics, one of them V must be child class of View, and class also should implement some interface MyInterface.

How to do that? I've tried something like this

class Test<T, V>(val value1: String, val map: Map<T, V>) where V: View, MyInterface

or

class Test<T, V>(val value1: String, val map: Map<T, V>) where V: View: MyInterface

but I have no idea what is the correct syntax?

1

There are 1 answers

1
Omar Silva On BEST ANSWER

class Test<T, V: View> (val string: String, val map: Map<T, V>) : MyInterface

Should be the correct syntax.