I am exploring Scala by rewriting some of my Java code with it. In one of the Java method, I need to pass a class type as a parameter:
public void setType(Class<T> type)
In Java, I could do it by:
someobj.setType( MyClass.class )
But in Scala, I can't seem to call "MyClass.class". I am wondering how I can pass the parameter in Scala?
You're after classOf[MyClass].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With