Created
January 28, 2018 08:29
-
-
Save izhangzhihao/0744426121a5227bbcf050619cb24119 to your computer and use it in GitHub Desktop.
Using.scala
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[C, T](resource: C)(handle: C => T)(implicit env: C => ({def close(): Unit})): T = { | |
try { | |
handle(resource) | |
} finally { | |
resource.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment