Created
June 25, 2021 06:39
-
-
Save saswata-dutta/bf2b44e734fb7a27faf142b1ce2a1db6 to your computer and use it in GitHub Desktop.
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 tryWithResource[R <: Closeable, T](createResource: => R)(f: R => T): T = { | |
val resource = createResource | |
try f.apply(resource) finally resource.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment