Help for this page

Select Code to Download


  1. or download this
       use Type::Standard -moose, qw(Int);
       use Type::Standard -mouse, qw(Int);
       use Type::Standard -moo,   qw(Int);
    
  2. or download this
       use v5.16;
       use Benchmark qw(cmpthese);
       
    ...
                Rate native     tt
       native 2511/s     --   -45%
       tt     4525/s    80%     --
    
  3. or download this
       use Moose::Util::TypeConstraints;
       
       coerce 'Str',
          from 'ArrayRef', via { join "\n", @$_ };
    
  4. or download this
       package MyClass {
          use Moose;
          use Types::Standard qw(ArrayRef Str);
    ...
             isa    => Str->plus_coercions(ArrayRef, sub { join "\n", @$_ 
    +}),
          );
       }
    
  5. or download this
       package MyClass {
          use Moose;
          use Types::Standard qw(Int);
    ...
             isa    => Int->where(sub { $_ % 2 == 0 }),
          );
       }
    
  6. or download this
       package MyClass {
          use Moose;
          use Types::Standard qw(ArrayRef);
    ...
             isa    => ArrayRef[Int],
          );
       }
    
  7. or download this
       use v5.16;
       
       package MyClass {
    ...
             return $self;
          }
       }