Suppose I have an object like:
object MyObj {
def apply(args: List[String])(implicit v: Int): Unit => Int = (_: Unit) => args.length + v
}
If I want to MyObj.apply, I have to do:
implicit val v = 5
val myObj = MyObj(List("a", "b", "c"))
myObj()
But that feels redundant. What I want to be able to do is:
implicit val v = 5
MyObj(List("a", "b", "c"))()
Unfortunately, that doesn't seem to work. The system complains that I'm missing my implicit arguments, which makes sense, but is a bummer.
Is there any way that I can call the function returned from the apply method directly without first assigning it to a value?