In Scala, is there a way to specify that a function should have default parameter values declared?
For example, in the code below, is there a way to specify in the signature of indirectHelloName that the provided function must provide a default value for the second parameter?
def helloName(name: String, greating: String = "hello"): Unit = {
println(s"$greating $name")
}
def indirectHelloName(name: String, function: (String,String) => Unit): Unit = {
if (name == "Ted") {
function(name, "Custom Greeting for Ted!")
} else {
function(name) //This would use the default value for the second argument.
}
}