Jump to content

Add a variable to a class instance at runtime: Difference between revisions

m
(added Morfa)
m (→‎{{header|Perl 6}}: monkey kebab)
Line 1,063:
On the other hand, mixins are frowned upon when it is possible to compose roles directly into classes (as with Smalltalk traits), so that you get method collision detection at compile time. If you want to change a class at run time, you can also use monkey patching:
 
<lang perl6>use MONKEY_TYPINGMONKEY-TYPING;
augment class Int {
method answer { "Life, the Universe, and Everything" }
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.