[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

This page is no longer maintained — Please continue to the home page at www.scala-lang.org

What is the Scala equivalent of Class.class in Java?

1 reply
Ikai Lan
Joined: 2009-03-15,
User offline. Last seen 42 years 45 weeks ago.
Suppose I have a User class. What is the equivalent of Java's "User.class" in Scala?
The use case here is that I'm working with Google App Engine. A Query object can be created like this:
persistenceManager.newQuery(User.class)
I'm not sure how to do this in Scala. Trying the above gives an "Identifier expected but class found" error on compilation.
David Hall 3
Joined: 2009-02-19,
User offline. Last seen 42 years 45 weeks ago.
Re: What is the Scala equivalent of Class.class in Java?

classOf[User]

scala> class User;
defined class User

scala> classOf[User];
res0: java.lang.Class[User] = class User

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland