title: Why this error : type mismatch; found : Unit required: String => Unit
body: <p>Below code : </p>
  
  <pre><code>object gen {
    println("Welcome to the Scala worksheet")
  
    case class CS(funToRun: String =&gt; Unit)
  
    val l: List[CS] = List(
  
      CS(open("filePath"))
  
      )
  
    def open(path: String): Unit = {
      java.awt.Desktop.getDesktop.open(new java.io.File(path))
    }
  }
  </code></pre>
  
  <p>causes compiler error : </p>
  
  <pre><code>type mismatch; found : Unit required: String =&gt; Unit
  </code></pre>
  
  <p>But my open function is of of type <code>String =&gt; Unit</code> and param type of funToRun is <code>String =&gt; Unit</code> ?</p>