Scala version of Java's try-with-resources or Python's "with".
Scala version of Java's try-with-resources or Python's "with".
Execute a block with an object that implements java.io.Closeable. Makes sure the item is closed when the block is left, even if an exception occurs. Also makes sure any Exceptions during close are treated according to best practice.
type of the closeable resource
return type of resource
the closeable resource
function block to be executed with the resource
the value of the block