A reusable type and collection of members that can be composed into a class in object-oriented programming. In Scala, a trait can declare required members and provide concrete implementations. Several traits can contribute mixin behavior to one class, subject to linearization and member-conflict rules.
Scala orders a class and its inherited traits to resolve member lookup and
super calls. For two independent traits sharing a base, the rightmost mixed-in trait comes first, followed by the earlier trait and then the common base. Ordinary virtual calls start at the receiver's most specific override; an unqualified super call starts after the implementation's owner in that receiver's linearization. It does not necessarily call the textual parent of the trait in isolation.[ref] Articles by others on the same topic
There are currently no matching articles.