Table of Contents

Scala - Trait (Interface)

About

Traits are like interfaces in Java, but they can also contain concrete members, i.e. method implementations or field definitions.

A trait, which is defined with the trait keyword;

A trait may be parameterized with one or more types.

When parameterized with types, the trait constructs a type. For example,

Also, Set is said to be “the trait of” type Set[Int].