小白在学习scala,练习了一个实例代码,虽然知道会输出空集合,但是其中的打印语句在idea下没有效果,如果使用控制台模式就可以打印,求大佬们解答。。
import scala.concurrent.Future
import scala.util.{Failure, Success, Try}
import scala.concurrent.ExecutionContext.Implicits.global
object FutureDemo1 {
def main(args: Array[String]): Unit = {
val doComplete:PartialFunction[Try[String],Unit] = {
case s @ Success(_) => println(s)
case f @ Failure(_) => println(f)
}
val future = (0 to 9) map {
case i if i%2 == 0 => Future.successful(i.toString)
case i => Future.failed(ThatsOdd(i))
}
future map(_ onComplete doComplete)
}
case class ThatsOdd(i:Int) extends RuntimeException{
s"odd $i received!"
}
}