title: How to unwrap an Option with its correct type in pattern matching?
body: <p>I have the following code that illustrates what I'd like to achieve but it doesn't compile ... I'd like to find out whether the <code>configMap</code> of type <code>Map</code> contains a key with value <code>"runOnGrid"</code> and if it does get its Boolean value.</p>
  
  <pre><code>val runOnGrid : Boolean = args.configMap.get("runOnGrid") match {
      case Some(value) : Option[Boolean] =&gt; value // &lt;=== compiler error
      case None =&gt; false
  }
  </code></pre>
  
  <p>but this doesn't work because I can't do <code>Some(value) : Option[Boolean]</code> namely I'm constrained to choose between matching by the value or by the type. To achieve this apparently I need better Scala kung fu ... can anyone advice?</p>
  
  <p>UPDATE: meantime I figured this <strong>horrendous</strong> way to do it</p>
  
  <pre><code>val runOnGrid = args.configMap.get(("runOnGrid") match {
      case Some(value) =&gt; value.isInstanceOf[Boolean] &amp;&amp; value.asInstanceOf[Boolean]
      case _ =&gt; false
  }
  </code></pre>
  
  <p>UPDATE: ConfigMap is defined inside Scalatest as:</p>
  
  <pre><code>class ConfigMap(underlying: Map[String, Any]) extends Map[String, Any] ...
  </code></pre>