Partially applying a function that has an implicit parameter

前端 未结 2 931
南方客
南方客 2021-01-04 01:42

Can I turn a method which takes an implicit parameter into a function?

trait Tx

def foo(bar: Any)(implicit tx: Tx) {}

foo _ // error: could not find implic         


        
2条回答
  •  遥遥无期
    2021-01-04 02:06

    Implicits only work for methods. But you have to pass a function to withSelection. You can get around by wrapping the method in a function:

    withSelection(a => b => deleteObjects(a)(b))
    

    Its impossible to pass deleteObjects directly because foo _ does not work for a foo with an implicit parameter list defined.

提交回复
热议问题