Scala implicit method with multiple arguments

In a comment for SIP-13, Martin Odersky implied that you could create an implicit method with several arguments. According to my experience, implicit methods always have exactly one argument, and I cannot imagine how to use an implicit method with several arguments. Can someone give an example of use and explanation?

+5
source share
1 answer

For example, if you need an implicit function type parameter:

implicit def foo(x: Int, y: Int) = y * x

def bar(x: Int, y: Int)(implicit f: (Int, Int) => Int) = f(x,y)

scala> bar(3,4)
res3: Int = 12
+7
source

All Articles