Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created December 17, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsolomon/0587b7d25dfa62d704ae815e57651261 to your computer and use it in GitHub Desktop.
Save andrewsolomon/0587b7d25dfa62d704ae815e57651261 to your computer and use it in GitHub Desktop.
Role applied to the class
{
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