Skip to content

Instantly share code, notes, and snippets.

// Doesn't compile. Good.
def futureInt(): Future[Int] = Future.value(Future.value(1))
// Compiles. Not good. Caller cannot wait on completion of nested future.
def futureUnit(): Future[Unit] = Future.value(Future.value(()))
// Also compiles. Nice convenience, but not worth the cost of the issues
// it might cause (as above), right?
def futureUnit(): Future[Unit] = Future.value(1)
@jlupien
jlupien / FutureUtil.scala
Last active January 3, 2016 09:09
"Unit" in Scala is a free-for-all?
// Doesn't compile. Good.
def futureInt(): Future[Int] = Future.value(Future.value(1))
// Compiles. Not good. Caller cannot wait on completion of nested future.
def futureUnit(): Future[Unit] = Future.value(Future.value(()))
// Also compiles. Nice convenience, but not worth the cost of the issues
// it might cause (as above), right?
def futureUnit(): Future[Unit] = Future.value(1)