Skip to content

Instantly share code, notes, and snippets.

@chrislewis
Created July 8, 2010 13:56
Show Gist options
  • Select an option

  • Save chrislewis/468030 to your computer and use it in GitHub Desktop.

Select an option

Save chrislewis/468030 to your computer and use it in GitHub Desktop.
def tryn[A <: AnyRef](f: => A) =
try {
f
} catch {
case _ => null.asInstanceOf[A]
}
// var someRef = tryn { obj.getSomethingButCauseEx }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment