i've defined 'using' keyword as following:
def using[A, B <: {def close(): Unit}] (closeable: B) (f: B => A): A =
try { f(closeable) } finally { closeable.close() }
i can use it like that:
using(new PrintWriter("sample.txt")){ out =>
out.println("hellow world!")
}
now i'm curious how to define 'using' keyword to take any number of parameters, and be able to access them separately:
using(new BufferedReader(new FileReader("in.txt")), new PrintWriter("out.txt")){ (in, out) =>
out.println(in.readLIne)
}