Mam następujący kod:
????
trzeba zastąpić poprawnymi typami. Ćwiczenie znalazłem w materiałach JetBrains, więc zakładam że da się je zrobić zamieniając tylko ????
. Pytanie jak to rozwiązać?
open class A
class B : A()
class C : A() { fun consume(other: A): C = this }
fun <T, S : R, R> funny(
source: Iterator<????>,
target: MutableCollection<????>,
base: ????,
how: ????
) {
var result: R = base
for (value in source) {
result = how(result, value)
target.add(result)
}
}
fun main() {
val wtf = mutableListOf<A>()
val src = mapOf(3.14 to B(), 2 to B(), "Hello" to B())
val c = C()
funny(src.values.iterator(), wtf, c) { r, t -> r.consume(t) }
}