Created
          January 5, 2011 07:18 
        
      - 
      
- 
        Save yuroyoro/766020 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | scala> class Foo[A](v:A)(implicit val mf:Manifest[A]){ | |
| | def typeParam = mf.erasure | |
| | } | |
| defined class Foo | |
| scala> (new Foo(99)).typeParam | |
| res2: java.lang.Class[_] = int | |
| scala> (new Foo("HOGE")).typeParam | |
| res3: java.lang.Class[_] = class java.lang.String | |
| scala> class Bar[A,B <:Seq[A]]( x:A,xs:B)(implicit val mfa:Manifest[A], val mfb:Manifest[B]) { | |
| | def typeParams = Seq( mfa.erasure,mfb.erasure ) | |
| | } | |
| defined class Bar | |
| scala> (new Bar("Foo",List("a","b","c"))).typeParams | |
| res4: (Seq[java.lang.Class[_ >: _$1 with _$1]] forSome { type _$1; type _$1 }) = List(class java.lang.String, class scala.collection.immutable.List) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment