ps0604 ps0604 - 1 year ago 91
Scala Question

How to convert .class in Scala

I have the following statement in Java that I need to convert to Scala:

MyClass myClass = object.method(MyClass.class);

Note that MyClass is a Java class, and object.method a Java method.

My attempt is

val myClass = object.method(MyClass.class)

however I get an error in
identifier expected but 'class' found
. How to convert this?

Answer Source

Scala equivalent of Java .class is classOf method


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download