Last active
March 5, 2018 15:30
-
-
Save foursixnine/bdd8477433340a59489eb69fb81d04f2 to your computer and use it in GitHub Desktop.
Multiple inheritance: Baz uses Bar as a base, who uses Foo as a base.
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
package Baz; | |
use base "Bar"; | |
1; |
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
package Foo; | |
sub new { | |
my $class = shift; | |
return bless {}, $class; | |
} | |
sub exclaim { | |
$self = @_; | |
print "I can have such a thing?!\n"; | |
} | |
1; |
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
package Bar; | |
use base "Foo"; | |
sub from_bar { | |
$self = @_; | |
"I come from Bar" | |
} | |
sub exclaim { | |
$self = @_; | |
print "I come from Bar\n"; | |
$self->SUPER::exclaim(); | |
} | |
1; |
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
use Baz; | |
my $ob = Baz->new(); | |
$ob->exclaim(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment