Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Exploring Type::Tiny Part 2: Using Type::Tiny with Moose

by tobyink (Canon)
on Aug 04, 2018 at 14:09 UTC ( [id://1219853]=CUFP: print w/replies, xml ) Need Help??

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;
          }
       }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://1219853]
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-19 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found