Effective Kotlin: Item 9 — Prefer try-with-resources to try-finally
Java 8 brings
try-with-resources to Java as an improvement to
try-finally when dealing with
Closeable resources. One of the reasons item 9 of Joshua Bloch’s book, Effective Java, suggests
try-with-resources as a winner is when dealing with multiple resources the ensuing nest of
try-finally blocks becomes ever harder to read.