Way to automatically convert class method to function taking explicit class argument in Scala?

function, scala

Solution

This way is 10 symbols shorter:

val af = (_: A).f _

Problem

The following is a manual process ``` case class A(x: Int) { def f(y: Int) = x * y } val af: (A => Int => Int) = _.f val a = A(4) val r = af(a)(2) ``` Is there a conventient way to get a function like `af`? Something like `A magic f`, possibly without using reflection. Ability to import all public methods of a class via `import A#magic._` is a bonus.

Original source