Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Created May 22, 2016 11:08
Show Gist options
  • Save jonathanstowe/beb1a3c3a906674e6ed694d0a34c6d16 to your computer and use it in GitHub Desktop.
Save jonathanstowe/beb1a3c3a906674e6ed694d0a34c6d16 to your computer and use it in GitHub Desktop.
multi BUILD annoying
role Foo {
has $!attribute;
multi submethod BUILD(:$!attribute!) {
say "with attribute";
}
}
class Bar does Foo {
multi submethod BUILD(Str :$foo!) {
say "with foo";
$!attribute = "default";
}
method foo() {
say $!attribute;
}
}
class Zub is Bar does Foo {
}
Bar.new(attribute => "set").foo;
Bar.new(foo => "something").foo;
Zub.new(attribute => "set").foo;
Zub.new(foo => "something").foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment