Created
May 22, 2016 11:08
-
-
Save jonathanstowe/beb1a3c3a906674e6ed694d0a34c6d16 to your computer and use it in GitHub Desktop.
multi BUILD annoying
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 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