I'm using the resource closure feature of Groovy, and was wondering if it was possible to create one closure that manages two resources. For example, if I have the following two separate closures, is it possible to create one closure that manages both? Or do I really have to nest the closures?
new File(baseDir, 'haiku.txt').withWriter('utf-8') { writer ->
writer.writeLine 'Into the ancient pond'
}
new Scanner(System.in).with { consoleInput ->
println consoleInput.nextLine()
}