Skip to content

Instantly share code, notes, and snippets.

@Centaur
Created May 17, 2016 04:12
Show Gist options
  • Save Centaur/9563f49541d7042bc239cc860ba3c2d3 to your computer and use it in GitHub Desktop.
Save Centaur/9563f49541d7042bc239cc860ba3c2d3 to your computer and use it in GitHub Desktop.
package org.snippets
import scala.concurrent.{Future, Promise}
class Test {
def test(): Function3[String, String, String, String] = {
new Function3[String, String, String, String] {
@throws(classOf[Exception])
override def apply(arg1: String, arg2: String, arg3: String): Future[String] = {
Promise[String]().future
}
}
}
def test1(): Function3[String, String, String, String] = { (a: String, b: String, c: String) =>
Promise[String]().future
}
}
trait Function3[-T1, -T2, -T3, +R] extends java.io.Serializable {
@throws(classOf[Exception])
def apply(arg1: T1, arg2: T2, arg3: T3): Future[R]
}
object Function3 {
def unapply[T1, T2, T3, R](arg: Function3[T1, T2, T3, R]): Option[Function3[T1, T2, T3, R]] = Some(arg)
implicit class ScalaFunction3IsMyFunction3y[T1, T2, T3, R](func3: (T1, T2, T3) => Future[R]) extends Function3[T1, T2, T3, R] {
@throws(classOf[Exception])
override def apply(arg1: T1, arg2: T2, arg3: T3) = func3.apply(arg1, arg2, arg3)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment