3 ms·
In Raku those things are also separate. 1. Polymorphism class Example { method be-nice () { 'be nice' } } class Bill-and-Ted
by b2gills 7y ago
In Raku those things are also separate.
1. Polymorphism
class Example {
method be-nice () {
'be nice'
}
}
class Bill-and-Ted is Example {
method be-nice () {
'be excellent to each other'
}
}
2. Composition
role Salaried {
has $.salary;
}
role Employee {
has $.title;
}
class Manager does Employee does Salaried {}
3. Delegation
class Price {
has $.cost;
}
class Product {
has Price $.inner handles( 'price' => 'cost' );
}
Any call to the `.price()` method on `Product` will delegate to the `.cost()` method on the inner object.