Invocation of methods with default parameters in scala higher-order function
问题 Supposedly I have a method that has one default parameter. I want to pass it as an argument to another method. How do I call the passed-in method with its default parameter ? def printNum(i: Int = 4): Unit = { println(i) } def doStuff(printFunc: (Int) => Unit): Unit = { // How to call printFunc with its default parameter printFunc() } doStuff(printNum) 回答1: I am afraid you cannot. Default parameter is property of methods, just like named arguments and things like this. When you pass it as a