I'm trying to write a simple converter that turns a java.util.Function
into a scala.Function1
:
def toScalaProducer[T](f: JavaFunction0[T]) : => T = => f()
Here is another variant that works well:
def toScalaFunction[T](f: JavaFunction0[T]) : () => T =
() => f.apply()
The problem is that I want to pass the converted function into an existing Scala API, but that API only accepts arguments of type => T
, not of type () => T
.
Is there a way to write the toScalaProducer
function?