https://kotlinlang.org logo
#getting-started
Title
# getting-started
c

Chris Cordero

07/10/2022, 11:06 PM
but it accepts this:
Copy code
import java.util.function.Supplier

class Bar(val x: Int)

fun foo(whatever: Supplier<out Bar>) {}

fun main() {
    val supplier = Supplier<Bar> { Bar(42) }
    foo(supplier) // compiler happy
}
r

Ruckus

07/11/2022, 1:43 AM
Because a
Supplier
is already
out
, but a
TypeReference
isn't.
💯 1
2 Views