useCloseable<R, C extends Closeable> function
R
useCloseable<R, C extends Closeable>(
- C resource,
- R fn(
- C p0
Runs passed function and closes this resource after it Closes the resource even if the function throws. The first exception thrown is propagated, if both the function and the close throw, the exception from the function is propagated
Implementation
R useCloseable<R, C extends Closeable>(
C resource,
R Function(C p0) fn,
) {
return resource.runAndClose<R>(fn);
}