Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created January 5, 2011 07:18
Show Gist options
  • Save yuroyoro/766020 to your computer and use it in GitHub Desktop.
Save yuroyoro/766020 to your computer and use it in GitHub Desktop.
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