title: What is the Scala identifier "implicitly"?
body: <p>I have seen a function named <code>implicitly</code> used in Scala examples. What is it, and how is it used?</p>
  
  <p><a href="https://stackoverflow.com/questions/3307427/scala-double-definition-2-methods-have-the-same-type-erasure/3798426#3798426">Example here</a>:</p>
  
  <pre><code>scala&gt; sealed trait Foo[T] { def apply(list : List[T]) : Unit }; object Foo {
       |                         implicit def stringImpl = new Foo[String] {
       |                             def apply(list : List[String]) = println("String")
       |                         }
       |                         implicit def intImpl = new Foo[Int] {
       |                             def apply(list : List[Int]) =  println("Int")
       |                         }
       |                     } ; def foo[A : Foo](x : List[A]) = implicitly[Foo[A]].apply(x)
  defined trait Foo
  defined module Foo
  foo: [A](x: List[A])(implicit evidence$1: Foo[A])Unit
  
  scala&gt; foo(1)
  &lt;console&gt;:8: error: type mismatch;
   found   : Int(1)
   required: List[?]
         foo(1)
             ^
  scala&gt; foo(List(1,2,3))
  Int
  scala&gt; foo(List("a","b","c"))
  String
  scala&gt; foo(List(1.0))
  &lt;console&gt;:8: error: could not find implicit value for evidence parameter of type
   Foo[Double]
         foo(List(1.0))
            ^
  </code></pre>
  
  <p>Note that we have to write <code>implicitly[Foo[A]].apply(x)</code> since the compiler thinks that  <code>implicitly[Foo[A]](x)</code> means that we call <code>implicitly</code> with parameters.</p>
  
  <p>Also see <a href="https://stackoverflow.com/q/11392622/203968">How to investigate objects/types/etc. from Scala REPL?</a> and <a href="https://stackoverflow.com/questions/5598085/where-does-scala-look-for-implicits">Where does Scala look for implicits?</a></p>