When I do specific class I would like to have better names for the params, since I know the context
w
wbertan
10/23/2019, 7:50 AM
Maybe something like
Copy code
interface Merger<T1 : Any, T2 : Any, R : Any> : (T1, T2) -> R
class B : Merger<String, String, Int> {
override fun invoke(asas1: String, asas2: String): Int = TODO()
}
wbertan
10/23/2019, 7:50 AM
Usage:
Copy code
fun asas() {
val b = B()
val result: Int = b("asas1", "asas2")
}
wbertan
10/23/2019, 7:52 AM
Or with the initial “interface”
Copy code
interface Merger1<T1 : Any, T2 : Any, R : Any> {
val merge: (T1, T2) -> R
}
class A : Merger1<String, String, Int> {
override val merge: (asas1: String, asas2: String) -> Int
get() = TODO()
}
fun asasA() {
val a = A()
val result: Int = a.merge("asas1", "asas2")
}
e
Eugen Martynov
10/23/2019, 8:32 AM
Nice!
k
kingsley
10/23/2019, 2:29 PM
You could also avoid an interface altogether with typealiases. So it becomes something like: