I have a method returning Unit originally. After changing returned type to Future[Unit], I can't find out a way to change the method body. The least line is a method call.
In Scala 2.12 the built-in Future.unit
is the way to go. It has the benefit of being cached.
You can return a Future
that holds a value of Unit
def doSomething():Future[Unit] = {
TimeUnit.SECONDS.sleep(3)
println("hi")
Future.successful(())
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With