Let's say I have this method:
def myMethod(value:File,x: (a:File) => Unit) = {
// some processing here
// more processing
x(value)
}
I know I can call this as:
myMethod(new File("c:/"),(x:File) => println(x))
Is there a way I could call it using braces? Something like:
myMethod(new File("c:/"),{ (x:File) =>
if(x.toString.endsWith(".txt")) {
println x
}
})
or do I have to write that in another method and pass that to myMethod
? I'd like to mention I'm new at Scala.