Last active
December 18, 2015 04:59
-
-
Save berekuk/5729809 to your computer and use it in GitHub Desktop.
moo-multi-before-with-moose
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 | |
# This code is working. | |
package R1; | |
use Moo::Role; | |
before 'foo', 'bar' => sub { | |
print "before\n"; | |
}; | |
package main; | |
use Moo; | |
with 'R1'; | |
sub foo {} | |
sub bar {} | |
main->foo; |
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 | |
# This code is broken. | |
# It prints the following error: | |
# Can't use string ("bar") as a subroutine ref while "strict refs" in use at /Users/mmcleric/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.3/darwin-2level/Class/MOP/Class.pm line 1079. | |
package R1; | |
use Moo::Role; | |
before 'foo', 'bar' => sub { | |
print "before\n"; | |
}; | |
package main; | |
use Moose; | |
with 'R1'; | |
sub foo {} | |
sub bar {} | |
main->foo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment