I have a function foo that accepts a Boolean function
def foo( f:(_)=>Boolean ) = //do something with f
I can call foo as follows
foo( (x:Int) => x == 0 )
Now, I want modify foo to accept any function that returns Boolean. eg. the modified foo should work for the following cases.
foo( (x:Int, y:Int) => x == y)
foo( (x:Int, y:Int, z:Int) => x == y && y == z)
foo( (x:Double, y:Double, z:Double, p:Double) => x < y && y < z && z < p)
//and so on...
My first attempt was to modify foo as follows
def foo2( f:(_*)=>Boolean ) = //do something with f
But this does not work.
What @Nicolas said.
You can make the call site code slightly nicer using
Function.tupled.