News for hackers. Stuff that matters.
Re:Garbage collection with Automatic Resource Management in ... by grepgrep on Monday January 16, 2012 @12:16PM (#3471481)
Rough example below, partially taken from a book I have on Scala.

//define it like this: def using[T <: {def close(): Unit }, S](obj: T) (operation: T => S) = { val result = operation(obj) obj.close() result }

//use it like this: val writer = new FunkyWriter using(writer) { writer.write("outputting some data") }

ARM was therefore possible in Scala before the Closable interface was even added to the Java libs.

There are no comments on this comment yet.