<Generic producer and consumer without exposing co...
# stackoverflow
u
Generic producer and consumer without exposing concrete types in Kotlin I've been reading up on Kotlin generics for a while and came to a sense that it's a very powerful feature of the language. This made me wonder and experiment, and I can't figure out a nice solution to the following problem. Say I have the following code: interface WidgetProducerConsumer { fun produce(): Widget fun consume(widget: Widget) companion object { fun getStringWidgetProducerConsumer(): WidgetProducerConsumer { return StringWidgetProducerConsumer()...