This short article will compare abstract classes and traits as means of inheritance.

If you're trying to figure out which is the best way to create OO-style type hierarchies and abstract classes seem too similar to traits, this article is for you.

So from this point of view, a trait and an abstract class are identical.

One of the fundamental differences between a trait and an abstract class is that multiple traits may be used in the inheritance definition of a class, whereas a single abstract class can be extended.

A second, more practical difference between a trait and an abstract class is that an abstract class can take constructor arguments: whereas traits cannot: That is, at least until Scala 3 comes out - Scala 3 will also allow constructor arguments for traits.

Related Articles