In scala is it possible to provide a default value for a parameter that is a function?
For example, in my code I have something like this.
def noop(): Unit = {}
def doSomethingGreat(succeed: Boolean)(f: => Unit)(default: => Unit = noop): Unit = {
if (success) {
f
} else {
default
}
}
When I try calling doSomethingGreat and I leave out a parameter for default, though, I get an error saying that I didn't pass in enough parameter. Any help?
So far, my workaround is to explicitly pass in a no-op function as the third parameter, but that defeats the purpose of having a default there in the first place...