Search code examples
scalaimplicit

Calling a curried function that uses an implicit


Given the function

def func(implicit x: Foo, y: Bar): (ThingA => ThingB) = ???`

I can't figure out how to call it on one line. Obviously this works by storing the returned function in a val:

val f = func // Foo and Bar are implicitly applied
f(ThingA)

but how to do it without the assignment to val? func(ThingA) naturally complains that func has been called with too few arguments.


Solution

  • The simplest is probably to explicitly call apply:

    func.apply(ThingA)