score:9

Accepted answer

First convert the method to a function, and then convert the function of two args into a function of one tuple.

Function.tupled(print _)(johnsmith)

score:10

In addition to Dave's answer, this works too:

(print _).tupled(johnsmith)

Usually, Function.tupled will work best for anonymous functions and closures in combination with map and similar methods. For example:

List("abc", "def", "ghi").zipWithIndex.map(Function.tupled(_ * _))

In this case, the type for _ * _ is already defined by Function.tupled. Try using tupled for that instead and it won't work, because the function is defined before tupled converts it.

For your particular case, tupled works, since the type of print is already known.


Related Query

More Query from same tag