title: How to pass an optional closure parameter to a function?
body: <p>I would like to pass a closure to a method as an Option and I am doing what is shown below. I get a compile error as shown below. Is it possible to pass an optional closure parameter to a function?</p>
  
  <pre><code>def sampleMethod(a: String, b: String, optionalMethod: Option[(String, Int) =&gt; Unit]) {
      // do some processing with a and b
      optionalMethod match {
        case Some(optionalMethod) =&gt; {
          optionalMethod("a",3)
        }
        case _
        log("no optional method passed")
      }
  }
  
  // definition of optMethod in some other place
  val optMethod = (c: String, d: Int) =&gt; {
    // some processing with c, d and external values 
  }
  
  // invoke
  sampleMethod("hi", "bye", optMethod) =&gt; FAILS TO COMPILE
  
  ERROR = type mismatch. expecting Option[(String, Int) =&gt; Unit] found (String, Int) =&gt; Unit
  </code></pre>