Skip to content

Instantly share code, notes, and snippets.

@pfn
Created February 7, 2012 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfn/1762813 to your computer and use it in GitHub Desktop.
Save pfn/1762813 to your computer and use it in GitHub Desktop.
using
def using[A <: { def close() }](closeable: => A)(f: A => Unit) {
var c: Option[A] = None
try {
c = Option(closeable)
c foreach f
} finally {
c foreach(_.close)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment