Content deleted Content added
m Reverted edits by 120.21.5.252 (talk) to last version by Narky Blert |
|||
Line 6:
Traits both provide a set of methods that implement behaviour to a class, and require that the class implement a set of methods that [[Parameter (computer programming)|parameterize]] the provided behaviour.
For inter-object communication, traits are
Hence an object defined as a trait is created as the composition of methods, which can be used by other classes without requiring [[multiple inheritance]]. In case of a [[naming collision]], when more than one trait to be used by a class has a method with the same name, the programmer must explicitly disambiguate which one of those methods will be used in the class; thus manually solving the ''[[Multiple inheritance#The diamond problem|diamond problem]]'' of multiple inheritance. This is different from other composition methods in object-oriented programming, where conflicting names are automatically resolved by [[Scope (computer science)|scoping rules]].
|