Created
August 8, 2009 20:21
-
-
Save ashgti/164492 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
#!perl6 | |
use v6; | |
role Logger { | |
method log ($msg) { | |
say self, ' logger says: ', $msg; | |
} | |
} | |
class Logger2 { | |
method log ($msg) { | |
say self, ' logger2 says: ', $msg; | |
} | |
} | |
class Foo is Logger2 does Logger { | |
method log ($self: $msg) { | |
say 'overridden'; | |
# a hack to directly call Logger::log($msg); | |
my $clone = self.clone; | |
$clone does Logger; | |
$clone.log($msg); | |
say 'done'; | |
} | |
method log2 ($msg) { | |
say 'overridden'; | |
# explicitly calling log from the class. | |
Logger2::log self, $msg; | |
} | |
} | |
my Foo $foo .= new; | |
$foo.log2("testing"); | |
$foo.log("testing"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment