Call a method with implicit parameter list

scala

with or without parentheses?

See blow example:

object App {

  class Dummy

  def foo(implicit dummy: Dummy): Unit = {
    println("foo called")
  }

  implicit val dummy: Dummy = new Dummy

  // correct
  foo

  // error: not enough argument
  //  foo()
}
  1. call foo is correct, as no argument supplied, an implicit value will be plugged in.
  2. call foo() is not correct as foo with empty parameter list is not defined. The correct signature needs one argument.

Note that if you want to add non implicit arguments, please add a new parameter list before the implicit one, coz implicit is applied to the whole list.

def foo(other: Int)(implicit dummy: Dummy): Unit = ()