I'm very new to scala and now I have to work on a project which is written both in scala and java. I came across with this-like construction:
class SomeType{
//...
}
trait Trait1 extends scala.AnyRef{
}
trait Trait2 extends extends scala.AnyRef{
}
class MyClass(arg : SomeType) extends Trait1{
//...
}
object MyClass extends Trait2{
//...
}
It's kind of mind-numbing. As far as I got by reading this answer we can think of object
s as just classes with abstract methods. I.e. we could (In my opinion) define some mapping with Class<T>
object in java.
But in this example class
and object
extends different trait
s. And that's what I was really confused by. I cannot imagine what it means and why it was used.