withPrintWriter( new File("date.txt"), writer => writer.println(new java.util.Date) )
(Q) How does Scala KNOW that "writer" in the statement "writer => writer.println(new java.util.Date)" is a java.io.PrintWriter? The only way I see it is through inference based on the function definition in "withPrintWriter()", right? Or there another way I should be understanding this?
As I understand this statement, this "sentByOneOf" val is a function type that takes a Set[String] and returns an EmailFilter (itself a function that takes an Email class and returns a Boolean) and this val is defined by logic that takes a "senders" val and returns a function that itself takes an "email" val that returns a Boolean result of evaluating the predicate "senders.contains(email.sender)". Right?
So, "senders" and "email" are "on-the-fly" vals? And the big question is how does Scala KNOW their types? I'm guessing again it is by inference to the functions to which they will be applied, yes?
Again, if someone has a different way of interpreting complex (complex to me) statements, I'd appreciate it. I'm still amazed at how much power we can get from such concise code.