Trait
Statement
Makes a trait, a construct that changes how a class or structure behaves.
Syntax
[ @Abstract ] Trait trait_name [ type_list ] [ Does parent_trait ]…
[ Where generic_constraints ]
…
[ statements ]
End [ Trait ]
Parts
@Abstract
- Optional modifier specifies that the trait contains only signatures of procedures, not executable statements or variables.
trait_name
- Mandatory name for the trait
type_list
- Optional one or more type parameters, with a comma between each, all between brackets (
[ ]
). See Type List for more information. Does
- Optional, you can use again and again.
parent_trait
- Mandatory after
Does
, a different trait from whichtrait_name
inherits methods. Where
- Optional, you can use again and again. See Where Clause (Generics) for more information.
statements
- Optional declarative statements.
End
- Completes the statement.
You can also use
End Trait
. - You can change this part of the syntax. See @Option Directive for more information.
Instructions
A trait defines a set of members that can become a part of the interface of classes and structures. If the trait does not implement a method or property, the class or structure must implement it. A trait that supplies only an interface, and does not implement its methods or properties, is known as an abstract trait.
When you make a class or structure that uses a trait, the code supplied by the trait becomes part of your class or structure. If a trait member is not implemented, you must implement that member in your class or structure.
You can use Trait only at module level. The declaration context can be a class, structure, module, or trait, and cannot be a procedure or block. See Declaration Contexts and Default Access Levels for more information.
Rules
TODO
Behavior
TODO
Examples
TODO