Skip to content

Instantly share code, notes, and snippets.

@ttldtor
Created September 17, 2014 19:54
Show Gist options
  • Save ttldtor/93d5851fc66057649e41 to your computer and use it in GitHub Desktop.
Save ttldtor/93d5851fc66057649e41 to your computer and use it in GitHub Desktop.
object StringUtils {
implicit class StringImprovements(val s: String) {
import scala.util.control.Exception._
def toIntOpt = catching(classOf[NumberFormatException]) opt s.toInt
def toLongOpt = catching(classOf[NumberFormatException]) opt s.toLong
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment