File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -445,7 +445,22 @@ but still aren't installed in a scope:
445
445
446
446
= head2 The C < augment > Declarator
447
447
448
- = comment TODO
448
+ With C < augment > , you can add attributes and methods to existing classes and
449
+ grammars, provided you activated the C < MONKEY-TYPING > pragma first.
450
+
451
+ Since classes are usually C < our > scoped, and thus global, this means modifying
452
+ global state, which is strongly discouraged. For almost all situations, there
453
+ are better soluations.
454
+
455
+ # don't do this
456
+ use MONKEY-TYPING;
457
+ augment class Int {
458
+ method is-answer { self == 42 }
459
+ }
460
+ say 42.is-answer; # True
461
+
462
+ (In this case, the better solution would be to use a
463
+ L < function|/language/functions > ).
449
464
450
465
= head2 The C < supersede > Declarator
451
466
You can’t perform that action at this time.
0 commit comments