Given an overloaded function, with one taking a function as parameter. This parameter-function takes no arguments:
def func(param: () => Unit): Unit = { param() } def func(param: Int): Unit = { println(param) } While calling func with an anonymous function works perfect:
func(() => println("it works")) Using a plain function fails:
def functionAsParam(): Unit = { println("it works") } func(functionAsParam) Obviously, Scala evaluates functionAsParam and don't pass the function itself to func. Question: How can I (as a user of a library which provides funcs) pass in a non-anonymous function?