What you are trying to do is not type-safe. You cannot assign (String, String, (Any, Any) => Unit) => Unit
to (Any, Any, Any) => Unit
. If you could, then you could do the following:
val f = second _
val af: (Any, Any, Any) => Unit = f
af(1, "abc", 5)
You can do it if you specify the types more precisely:
def second(string1: String, string2: String, func: (String, String) => Unit) = {
func(string1, string2)
}
def third(string1: String, string2: String) = {
// operations
}
def first(string1: String, string2: String, func: (String, String, (String, String) => Unit) => Unit) = {
func(string1, string2, third)
}