title: String to Int in Scala
body: <p>Suppose I need to convert a String to Int in Scala. If the string is not a number I would like to return <code>None</code> rather than throw an exception.</p>
  
  <p>I found the following <a href="https://coderwall.com/p/lcxjzw" rel="nofollow">solution</a></p>
  
  <pre>
  def toMaybeInt(s:String) = {
    import scala.util.control.Exception._
    catching(classOf[NumberFormatException]) opt s.toInt
  }
  </pre>
  
  <p>Does it make sense ? Would you change/improve it ?</p>