Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created July 1, 2012 15:33
Show Gist options
  • Save ynonp/3028758 to your computer and use it in GitHub Desktop.
Save ynonp/3028758 to your computer and use it in GitHub Desktop.
package Pet;
use Moose;
has 'name', is => 'ro', isa => 'Str', default => 'Nemo';
has 'past_owners', is => 'ro', isa => 'ArrayRef[Str]';
package main;
my $dog = Pet->new( past_owners => ['James', 'Mike'] );
# show dog's info. No need to import Data::Dumper
warn $dog->dump;
# DOES returns true for objects of the class, subclasses or
# implementors of the role
print "Good boy" if $dog->DOES('Pet');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment