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

Czar

10/03/2017, 12:10 PM
after
use
execution both first and second will be closed, so the object becomes unusable. I'm sorry for so many uses of the word 'use', but here I kinda have to 😄
m

marstran

10/03/2017, 12:56 PM
Why can't you just do the nesting inside the
use
function, instead of implementing manually. The whole implementation would be this:
first.use { a -> second.use { b -> useBlock(a, b) } }
.
c

Czar

10/03/2017, 1:11 PM
I'm just solving theoretical a problem as it is formulated by Olekss. If I needed to use two closeables I would've used nesting as you suggest. This is just esoteric practice 🙂
m

marstran

10/03/2017, 1:16 PM
Yes, I know that 😉 I'm just suggesting that the implementation of the
use
function in
UsablePair
could just be what I wrote in my last comment. You don't really need that big try-catch statement.
b

beholder

10/03/2017, 1:30 PM
IMO, two nested statements is not "big"
m

marstran

10/03/2017, 1:31 PM
No, I was referring to the try-catch as "big".
c

Czar

10/03/2017, 1:57 PM
Oh, I see now, you definitely make a good point. I deliberately didn't want to use
use
. Wanted to see how implementation from scratch would look like.
5 Views