Is there some trick which would, with a proper replacement of ???, ensure that
the following code:
===
class Foo {
void ???() { println "Hi" }
void close() { println "Bye" }
}
...
def foo=new Foo()
println "1"
try (foo) { println "2" }
println "3"
try (foo) { println "4" }
println "5"
===
prints out 1,Hi,2,Bye,3,Hi,4,Bye,5?
I'd rather like not to create a new foo object for each try block (which of
course would be sorta-solution); it would be _considerably_ more convenient to
reuse it -- if there was a way for that to know it enters the try block.
Thanks!
OC