为什么在以下代码中,即使返回类型为Future[Future[Unit]]
而不是Future[Unit]
,编译器也不会给出错误?
//compiles even though return is Future[Future[Unit]]. Not expected.
def test1:Future[Unit] = Future{
Future{ println("something")}
}
//doesn't compile because return is Future[Future[Int]] . Expected
def test:Future[Int] = Future{
Future{1}
}