https://kotlinlang.org logo
#announcements
Title
# announcements
m

marstran

10/03/2017, 10:54 AM
I guess you could create your own extension function like this:
Copy code
fun <T1: Closeable?, T2: Closeable?, R> Pair<T1, T2>.use(block: (T1, T2) -> R): R =
            first.use { a -> second.use { b -> block(a, b) } }
You could then do
(Buffer() to Okio.source(file)).use { buffer, source -> ... }
.
i

ilya.gorbunov

10/03/2017, 2:41 PM
Note that this will leave
Buffer
opened if
Okio.source(file)
throws an exception.
2 Views