Created
January 9, 2016 19:38
-
-
Save timvw/fb23dbd5098b63d44f9c to your computer and use it in GitHub Desktop.
Scala type refinement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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