title: Scala: Are these two partial functions equivalent?
body: <p>Are these two partial functions equivalent?</p>
  
  <pre><code>val f0: PartialFunction[Int, String] = {
    case 10 =&gt; "ten"
    case n: Int =&gt; s"$n"
  }
  
  val f1 = new PartialFunction[Int, String] {
    override def isDefinedAt(x: Int): Boolean = true
    override def apply(v: Int): String = if (v == 10) "ten" else s"$v"
  }
  </code></pre>
  
  <p><em>UPD</em></p>
  
  <pre><code>val pf = new PartialFunction[Int, String] {
    def isDefinedAt(x: Int) = x == 10
    def apply(v: Int) = if (isDefinedAt(v)) "ten" else "undefined"
  }
  
  def fun(n: Int)(pf: PartialFunction[Int, String]) = pf.apply(n)
  println(fun(100)(pf))
  </code></pre>
  
  <p>Is it truly PF now?</p>