So basically I want to write a function that can be written as follows:
{ println(_) } =: thing
Here I want it to actually do thing.=:(println(_))
. Assume that the argument =:
has the following implementation:
def =:(block : Int => Any) { block(5) }
So I try to call it higher, and I get:
<console>:10: error: type mismatch; found : Unit required: Int => Any println(_) =: thing
Then I will try to do this:
thing.=:(println(_))
This way I get a nice 5
printed on the terminal. Then I tried this:
{ value => println(value) } =: thing
This failed again and informed me that there is a "missing parameter type". I assume this is because Scala tries to parse / compile the function argument first in this case and not guess the type like it (I guess completely here) when it is called in a more ordinary way (with the point operator).
Can someone shed more light on the problems here, and can also offer a better way to achieve something close to my original goal?
PS Sorry for the title. I will rename it when I have a better understanding of the problem.
source share