Reputation: 3066
From the link http://www.scala-lang.org/old/node/117
It gives an example that a trait extends an abstract class. Since abstract class has constructor, how could it happen? Does it mean abstract class and trait have the same position?
Upvotes: 1
Views: 475
Reputation: 3343
They are for sharing interfaces, fields and type between classes and both of them are not instantiatable. And a abstract class extends a trait and vice versa. But since A class in scala can extend only one superclass,
abstract class A
abstract class B
trait AA extends A
class C extends AA // ok class C's super class is A
class C extends B with AA // NG trying to have 2 super class
like I mentioned at the beginning, they are non-instantiatable. So You do not need to care the abstract class's constructor. It will be called when a class which extends it is created and instantiated.
Upvotes: 1