use strict;
use warnings;
{
package Cat;
use Moose;
has name => (
is => 'ro',
isa => 'Str',
);
__PACKAGE__->meta->make_immutable;
}
{
package Litter;
use Moose;
has cats => (
is => 'ro',
isa => 'ArrayRef[Cat]',
);
__PACKAGE__->meta->make_immutable;
}
my $cat1 = Cat->new(name=>'Garfield');
my $cat2 = Cat->new(name=>'Felix');
my $litter = Litter->new(cats => [$cat1, $cat2, 1]);
####
use strict;
use warnings;
{
package Cat;
use Moo;
use Types::Standard -types;
has name => (
is => 'ro',
isa => Str,
);
}
{
package Litter;
use Moo;
use Types::Standard -types;
has cats => (
is => 'ro',
isa => ArrayRef[InstanceOf['Cat']],
);
}
my $cat1 = Cat->new(name=>'Garfield');
my $cat2 = Cat->new(name=>'Felix');
my $litter = Litter->new(cats => [$cat1, $cat2, 1]);
####
use Moops;
class Cat :ro {
has name => (isa => Str);
}
class Litter :ro {
has cats => (isa => ArrayRef[InstanceOf['Cat']]);
}
my $cat1 = Cat->new(name=>'Garfield');
my $cat2 = Cat->new(name=>'Felix');
my $litter = Litter->new(cats => [$cat1, $cat2, 1]);
####
use strict;
use warnings;
use Types::Standard -types;
use MooX::Struct Cat => ['$name'];
use MooX::Struct Litter => ['@cats' => [ isa => ArrayRef[InstanceOf[Cat]] ]];
my $cat1 = Cat->new(name=>'Garfield');
my $cat2 = Cat->new(name=>'Felix');
my $litter = Litter->new(cats => [$cat1, $cat2, 1]);
####
use strict;
use warnings;
use MooseX::Struct;
immutable struct Cat => (
name => { isa => 'Str' },
);
immutable struct Litter => (
cats => { isa => 'ArrayRef[Cat]' },
);
my $cat1 = Cat->new(name=>'Garfield');
my $cat2 = Cat->new(name=>'Felix');
my $litter = Litter->new(cats => [$cat1, $cat2, 1]);