Related topics
Trait (computer programming)
In computer programming, a trait is a language concept that represents a set of methods that can be used to extend the functionality of a class. RationaleIn object-oriented programming, behavior is sometimes shared between classes which are not related to each other. For example, many unrelated classes may have methods to serialize objects to JSON. Historically, there have been several approaches to solve this without duplicating the code in every class needing the behavior.
*As an Amazon Associate I earn from qualifying purchases.