diff --git a/language/oop5/traits.xml b/language/oop5/traits.xml index b8787334a0..3929988e1a 100644 --- a/language/oop5/traits.xml +++ b/language/oop5/traits.xml @@ -19,40 +19,7 @@ requiring inheritance. - - Precedence - - An inherited member from a base class is overridden by a member inserted - by a Trait. The precedence order is that members from the current class - override Trait methods, which in return override inherited methods. - - - - - Multiple Traits - - Multiple Traits can be inserted into a class by listing them in the use - statement, separated by commas. - - - - - Conflict Resolution - - If two Traits insert a member by the same name, a fatal error is produced, - if the conflict is not explicitly resolved. - - - To resolve conflicted naming among Traits, one can use the insteadof - operator to explicitly define the precedence between said Traits. Or, - one can use the as operator to alias the conflicting - member name(s). - - - - - &reftitle.examples; - + Trait example - + + + Precedence + + An inherited member from a base class is overridden by a member inserted + by a Trait. The precedence order is that members from the current class + override Trait methods, which in return override inherited methods. + + Precedence Order Example An inherited method from a base class is overridden by the @@ -116,8 +91,8 @@ Hello World! ]]> - - Precedence Order Example #2 + + Alternate Precedence Order Example - + + + + Multiple Traits + + Multiple Traits can be inserted into a class by listing them in the use + statement, separated by commas. + + Multiple Traits Usage - + + + + Conflict Resolution + + If two Traits insert a member by the same name, a fatal error is produced, + if the conflict is not explicitly resolved. + + + To resolve conflicted naming among Traits, one can use the insteadof + operator to explicitly define the precedence between said Traits. Or, + one can use the as operator to alias the conflicting + member name(s). + + Conflict Resolution - + + + + Traits Composed from Traits + + Just as classes can make use of traits, so can other traits. By using one + or more traits in a trait definition, it can be composed partially or + entirely of the members defined in those other traits. + + Traits Composed from Traits - + + + + Abstract Trait Members + + Traits support the use of abstract methods in order to impose requirements + upon the exhibiting class. + + Express Requirements by Abstract Methods - + + + + Static Trait Members + + Static variables can be referred to in trait methods, but cannot be + defined by the trait. Traits can, however, define static methods for + the exhibiting class. + + Static Variables - + Static Methods + +vi: ts=1 sw=1 +-->