问题描述:

I want to pass a class as a parameter to my function in Scala.

e. g. def getIndexes(...): Iterator

this is like the structure of function

I want to pass something like Vertex.class or say Edge.class as my parameter.

网友答案:

If your are not after a type parameter to the method as per Gabriele's answer, but actually want to pass a Class object as a parameter, the type of the class object in Scala is parametric, so to accept any class you would do:

def myMethod(aClass: Class[_])
网友答案:

Would passing a type parameter work for you?

def getIndexes[T]()
相关阅读:
Top