title: Pattern matching on generic type in Scala
body: <p>I have scala function that looks like this:</p>
  
  <p>Now, depending upon the type of T (In my case, it can be <code>Double</code>, <code>Boolean</code> and <code>LocalDate</code>),
  I need to apply functions on <code>ob</code>. Something like this (I know the code will make no sense but I am trying to convey what I mean to do):</p>
  
  <pre><code>def X[T](ob: Observable[T]): Observable[T] = {
      //code  
      T match {
      case Double =&gt; DoSomething1(ob:Observable[Double]):Observable[Double]
      case Boolean =&gt; DoSomething2(ob:Observable[Boolean]):Observable[Boolean]
      case LocalDate =&gt; DoSomething3(ob:Observable[LocalDate]):Observable[LocalDate]
      }
  }
  </code></pre>
  
  <p>Taking into consideration the Erasure property of Scala, can reflection be somehow used to get the job done? Is it even possible?</p>