An idiomatic way of converting an Option[String] into an Option[Int] in Scala
This always returns an Option[Int]
Option("bad") filter { _ != None } map { catching(classOf[NumberFormatException]) opt _.toInt } getOrElse None
This always returns an Option[Int]
Option("bad") filter { _ != None } map { catching(classOf[NumberFormatException]) opt _.toInt } getOrElse None