Created
July 12, 2019 21:33
-
-
Save varmas/77d023c30b2fbaea30e62b3f754ce6fb to your computer and use it in GitHub Desktop.
a safe resource closer
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
private def withSafeClose[A](source: Closeable)(op: Closeable => A): A = { | |
try { | |
op(source) | |
} finally { | |
source.close() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment