Why scala Try-match matches Throwable as success

Viewed 160
Try(
  new Throwable
)match {
  case Success(_) => println("Success")
  case Failure(exception) => exception.printStackTrace()
}

This code print "Success"

Scala version 2.11.12

1 Answers

Because

new Throwable

is just a regular value unlike

throw new Throwable

which aborts evaluation.

Related