|
Problem:
You want to add an attribute or method to a class, or change the value or implementation of an existing attribute/method, but only under certain (runtime) conditions. Solution:
Use code like the following:
Discussion: Perl6 allows you to modify the structure of a class even at runtime, if that class does not specifically forbid it. There are a number of circumstances in which you may not add an attribute or method to a class, or modify an existing attribute or method. Among them:
If you are merely defining a new implementation of a method, but don't want to change the signature of the old method, don't put signature information in the anonymous method constructor:
In addition to being much more compact, the second form makes it much easier to ensure you're really making a method with the signature that's expected. (You don't have to worry about typos, for starters.)
Issue:
Or will we be using
|