2013-04-10 22:43:41 -07:00
|
|
|
subset Eatable of Any where { .^can('eat') };
|
|
|
|
|
|
|
|
|
|
class Cake { method eat() {...} }
|
|
|
|
|
|
2016-12-05 22:15:40 +01:00
|
|
|
role FoodBox[Eatable] {
|
|
|
|
|
has %.foodbox;
|
2013-04-10 22:43:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Yummy does FoodBox[Cake] { } # composes correctly
|
|
|
|
|
# class Yucky does FoodBox[Int] { } # fails to compose
|
|
|
|
|
|
|
|
|
|
my Yummy $foodbox .= new;
|
|
|
|
|
say $foodbox.perl;
|