Scala-Java interoperability: is passing a Java function to Scala as a higher-order function possible?

25 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Denis Papathanasiou

ungelesen,
23.08.2016, 20:52:5723.08.16
an scala-user
I have a project with two modules, one in Scala, and the other in Java.

I need the Java module because it makes a call to an internal data store
(using home-brewed libraries) that would be difficult to replicate
in Scala.

But I prefer the Scala module to handle the concurrency that calls to
the data store involve.

So while I cannot make the data store queries directly in Scala (which
would have been ideal), I would like a simple way of passing the Java
query as a higher-order function to my Scala module.

Is this possible? I do have Java 8 at my disposal for the Java module.

Seth Tisue

ungelesen,
23.08.2016, 21:02:0023.08.16
an scala-user
scala.runtime.AbstractFunctionN is your friend. on Java 8, https://github.com/scala/scala-java8-compat is your friend. see http://stackoverflow.com/a/8380694/86485

Denis Papathanasiou

ungelesen,
23.08.2016, 21:19:5823.08.16
an scala-user
Terrific, this is exactly what I was looking for, thank you!
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten