mixel mixel - 1 year ago 205
Scala Question

Scala package object getClass

I want to get

for Scala package object:


package object app {


package app

object Main extends App {
val _ = app.getClass

Compilation fails with:

object getClass is not a member of package app Note that app extends
Any, not AnyRef. Such types can participate in value classes, but
instances cannot appear in singleton types or in reference

Answer Source

You can define method inside app returning class:

package object app {
  def cls = getClass
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download