Created
December 17, 2017 14:12
-
-
Save andrewsolomon/0587b7d25dfa62d704ae815e57651261 to your computer and use it in GitHub Desktop.
Role applied to the class
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 Brand; | |
use Moo::Role; | |
has name => ( is => 'ro' ); | |
sub description { "This is a nice ". shift->name } | |
} | |
{ | |
package Car; | |
use Moo; | |
with 'Brand'; | |
} | |
say Car->new ( name => "Peugeot" )->description; # Good usage | |
say Car->new->description; # Bad usage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment