I\'m looking to pass a Class as a parameter to a Scala function like so:
def sampleFunc (c : Class) : List[Any]
(Side question: should the ty
Yes. In general case it's ClassTag/TypeTag - see Mirrors and Reflection
import scala.reflect._
def runtimeClass[T: ClassTag] = classTag[T].runtimeClass
scala> runtimeClass[String]
res2: Class[_] = class java.lang.String
If you really need only to check compile-time (formal) type equality
scala> implicitly[String =:= Double]
:14: error: Cannot prove that String =:= Double.
implicitly[String =:= Double]
^
If you really need to check only type of object:
scala> "aa".isInstanceOf[String]
res4: Boolean = true