When passing multiple parameters, you must use parentheses around them. Using {} works only for single parameters.
Also, when using function literals, if you specify a type, you must put all the parameters of the functions in parentheses.
So,
def withLoaner = new { def apply(n:Int, op: Int => String):String = (1 to n).map(op).mkString("\n") def apply(n:Int, op: () => String):String = apply(n, i => op()) // no type on i def apply(op: () => String):String = apply(1, (i: Int) => op()) // parenthesis around parameters }
source share