Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created July 2, 2012 12:00
Show Gist options
  • Save ynonp/3032904 to your computer and use it in GitHub Desktop.
Save ynonp/3032904 to your computer and use it in GitHub Desktop.
use v5.14;
package Student;
use Moose;
use Moose::Util::TypeConstraints;
subtype 'GradesArray', as 'ArrayRef[Int]';
coerce 'GradesArray', from 'Int', via { [ $_ ] };
has 'grades', is => 'ro', isa => 'GradesArray', coerce => 1;
package main;
my $s = Student->new( grades => 77 );
print $s->dump;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment