Suppose that I have a string in scala and I want to try to parse a double out of it.
I know that, I can just call toDouble and then catch the java num
toDouble
Scala 2.13 introduced String::toDoubleOption:
Scala 2.13
"5.7".toDoubleOption // Option[Double] = Some(5.7) "abc".toDoubleOption // Option[Double] = None "abc".toDoubleOption.getOrElse(-1d) // Double = -1.0