Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- role Bar {
- COMPOSE {
- print "Bar() was composed into: ";
- print $_; # => What your being composed into
- print " and {$_} was defined: ";
- say $_.defined; # How to tell if its a class instance or an object instance
- }
- }
- class Foo does Bar {
- INHERIT {
- print "Foo() was inherited into child: ";
- print $_; # => What your being inherited into
- }
- }
- class Child is Foo {
- }
- class GrandChild is Child {
- }
- my $i = 123;
- $i does Bar;
- =begin pod
- expected output:
- Bar() was composed into: Foo() and Foo() was defined: 0
- Foo() was inherited into child: Child()
- Foo() was inherited into child: GrandChild()
- Bar() was composed into: 123 and 123 was defined: 1
- =end pod
Add Comment
Please, Sign In to add comment