Object-Oriented Programming

Trait

English

Overview

A reusable collection of methods used to add functionality to a class.

Details

In languages that only support single inheritance, traits provide a safe way to gain flexibility similar to having multiple parent classes (a benefit similar to multiple inheritance). The exact specification differs by language—PHP and Rust each implement it somewhat differently—but it plays a role similar to a mixin.

More Programming terms