Since Kotlin has a strong type-inference, and seems like compiler already know the type which has to be received as parameter to lambda (in the function call), is it possible to reduce the redundant generic E of EventE, and the second generic parameter E itself?
Animesh Sahu
09/24/2020, 3:53 PM
Ah, found it. We have to remove the generic completely to remove explicit writing of the second generic as well.
But can we remove the <Int> as well? Since it is implicit, as coming from the type of ObservableList.
a
araqnid
09/26/2020, 3:03 PM
I don’t think so, I think if you name the type you have to give its arguments as well.
I assume you’re trying to avoid having specific binding methods like
onAdd
?
Copy code
fun <E> ObservableCollection<E>.onAdd(
scope: CoroutineScope = this,
consumer: suspend (ElementAddEvent<E>) -> Unit
) {
on(scope, consumer)
}