I have a question regarding a trick
new PrintWriter("/tmp/some.file") { write("file contents"); close }
that I learned from this interesting post: Scala: write string to file in one statement
The technique works great (for test code), however I am a little puzzled about what is going on syntactically in Scala.
PrintWriter is a java class... but it looks like a code block is being passed to the print writer instance, and implicitly method calls are being executed on that instance. The PrintWriter java class definition has no apply() method that takes a function block.
So .. I'm puzzled as to what is going on visa vi Scala syntax
thanks !