Skip to content

Instantly share code, notes, and snippets.

@timvw
Created January 9, 2016 19:38
Show Gist options
  • Select an option

  • Save timvw/fb23dbd5098b63d44f9c to your computer and use it in GitHub Desktop.

Select an option

Save timvw/fb23dbd5098b63d44f9c to your computer and use it in GitHub Desktop.
Scala type refinement
def using[T <: { def close(): Unit }, S](obj: T)
(operation: T => S) = {
val result = operation(obj)
obj.close()
result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment