Created
May 6, 2010 20:37
-
-
Save ashgti/392673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment