- or download this
use DateTime;
subtype DateTime => as Object => where { $_->isa('DateTime') };
- or download this
use DateTime;
subtype 'DateTime' => as 'Object' => where { $_->isa('DateTime') };
- or download this
use strict;
use warnings;
...
print "Is $thing new? ".$obj->is_new($thing);
$thing = to_NewType('House');
print "Is $thing new? ".$obj->is_new($thing);
- or download this
package TmpTypes;
use strict;
...
coerce NewType,
from Str,
via { 'new_'.$_ };
- or download this
subtype 'NewType',
as 'Str',
where {$_ =~ /^new_/};
...
coerce 'NewType',
from 'Str',
via { 'new_'.$_ };
- or download this
use strict;
use warnings;
use Moose::Util::TypeConstraints;
...
print "Is $thing new? ".$obj->is_new($thing);
$thing = to_NewType('House');
print "Is $thing new? ".$obj->is_new($thing);
- or download this
package TmpTypes;
use strict;
...
coerce 'NewType',
from 'Str',
via { 'new_'.$_ };