Skip to content

Instantly share code, notes, and snippets.

@anishpatel
Created November 14, 2015 03:52
Show Gist options
  • Save anishpatel/2dcd54f96781567c5248 to your computer and use it in GitHub Desktop.
Save anishpatel/2dcd54f96781567c5248 to your computer and use it in GitHub Desktop.
import scala.collection.immutable.List;
abstract class ForkJoin {
protected def getList[T]: List[T]
def apply[A, B]: (List[A], List[B]) = {
(getList[A], getList[B])
}
}
object ForkJoin {
def main(args: Array[String]) = {
val forkJoin = new ForkJoin {
override protected def getList[T]: scala.List[T] =
List.empty[T]
}
val (intList, stringList) = forkJoin[Int, String]
println(3 :: intList)
println("Hello" :: stringList)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment