Since Kotlin has a strong type-inference, and seem...
# announcements
a
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?
Ah, found it. We have to remove the generic completely to remove explicit writing of the second generic as well.
Copy code
ObservableList<Int>().on { event: ElementAddEvent<Int> ->

}
But can we remove the <Int> as well? Since it is implicit, as coming from the type of ObservableList.
a
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)
}
a
Now I think it'll be ok to have <E> passed 🙂
Passing <E> twice was the main problem, it has been solved by using star-projections as answered by bsimmons here https://kotlinlang.slack.com/archives/C0922A726/p1601127461088600?thread_ts=1601053486.066000&amp;cid=C0922A726