Thursday, May 27, 2010

Scala Manifest

Idiomatic way to reflect on scala type


scala> def gt[A](x : A)(implicit m:Manifest[A]) = m
gt: [A](x: A)(implicit m: scala.reflect.Manifest[A])scala.reflect.Manifest[A]

scala> val l = 1 to 10
l: scala.collection.immutable.Range.Inclusive with scala.collection.immutable.Range.ByOne = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> gt(l)
res8: scala.reflect.Manifest[scala.collection.immutable.Range.Inclusive with scala.collection.immutable.Range.ByOne] = scala.collection.immutable.Range$Inclusive with scala.collection.immutable.Range$ByOne

No comments: