Try(
new Throwable
)match {
case Success(_) => println("Success")
case Failure(exception) => exception.printStackTrace()
}
此代码打印“成功”
Scala 版本 2.11.12
最佳答案
因为
new Throwable
只是一个常规值,不像
throw new Throwable
中止评估。
https://stackoverflow.com/questions/66420932/