I'm trying to Inherite one object from another

2019-08-30 23:26发布

问题:

I want to inherit one object from another:

object ws1 {
  object Obj1
  object Obj2 extends Obj1
}

It complains: not found type Obj1

回答1:

You can't inherit form objects. Change your code to the following and you should be a happier camper than before:

object ws1 { 
  class Obj1
  object Obj1 extends Obj1
  object Obj2 extends Obj1
}


标签: scala