declarator augment
1 | language documentation Variables |
1.1 | (Variables) declarator augment |
Documentation for declarator augment
assembled from the following types:
language documentation Variables
From Variables
(Variables) declarator augment
With augment
, you can add methods, but not attributes, to existing classes and grammars, provided you activated the MONKEY-TYPING
pragma first.
Since classes are usually our
scoped, and thus global, this means modifying global state, which is strongly discouraged. For almost all situations, there are better solutions.
# don't do thisuse MONKEY-TYPING;augmentsay 42.is-answer; # OUTPUT: «True»
(In this case, the better solution would be to use a function).