Skip to content

Instantly share code, notes, and snippets.

@kareblak
Created November 8, 2012 21:54
Show Gist options
  • Save kareblak/4041949 to your computer and use it in GitHub Desktop.
Save kareblak/4041949 to your computer and use it in GitHub Desktop.
implicit val convDouble = convOption[Double](_.toDouble)_
implicit val convInt = convOption[Int](_.toInt)_
implicit val convString = convOption[String](_.toString)_
def convOption[T](f: String => T)(s: String) = try { Some(f(s)) } catch { case _ => None }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment