is there any way to do something like this : ```in...
# announcements
is there any way to do something like this :
Copy code
interface BaseInterface<F,I> {
fun example(foo: F, params: I? = null)

I want to add params but as a generic on a method is there any idiomatic way to do it? But I do not want to declare it for every classes that implements this AnInterface
I think
fun example(foo:F, vararg params:I)
will do it. I believe a
is optional. params will be an Array<I>.
But I want it to be transparent for these who are using BaseInterface, otherwise I'll have to edit different classes
See below the example
Then no. An Interface is a contract, so all inheritors have to implement it. If something has extras, then it can define it, but it won't be visible through the parent interface. That's the nature of OO. The caller would have to know whether the param is required or not anyway, right?