Created
October 1, 2013 19:22
-
-
Save prakashk/6783710 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
#!/usr/bin/env perl | |
use v5.14; | |
use mop; | |
use Data::Printer; | |
class Foo { | |
has $!foo is ro; | |
method new($class: $foo) { | |
say "# Foo::new($foo)"; | |
$class->next::method(foo => $foo); | |
} | |
submethod BUILD($args) { | |
say "# Foo::BUILD(", p($args), ")"; | |
$!foo = $args->{foo} if exists $args->{foo}; | |
} | |
} | |
class Bar extends Foo { | |
has $!bar is ro; | |
method new($class: $foo, $bar) { | |
say "# Bar::new($foo, $bar)"; | |
$class->next::method($foo); | |
} | |
submethod BUILD($args) { | |
say "# Bar::BUILD(", p($args), ")"; | |
$!bar = $args->{bar} if exists $args->{bar}; | |
} | |
} | |
my $bar = Bar->new(10, 42); | |
p mop::dump_object($bar); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
What should change in order to intialize Bar object properly?