Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Best guess for data type

by tobyink (Abbot)
on Apr 22, 2013 at 16:55 UTC ( #1029927=note: print w/ replies, xml ) Need Help??


in reply to Best guess for data type

use v5.10; use strict; use warnings; use Types::Standard qw( ArrayRef Str Num Int ); my $arr = [ 1, 2, 3.3 ]; if ($arr ~~ ArrayRef[Int]) { say "ArrayRef of Int" } elsif ($arr ~~ ArrayRef[Num]) { say "ArrayRef of Num" } elsif ($arr ~~ ArrayRef[Str]) { say "ArrayRef of Str" }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: Best guess for data type
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029927]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-12-21 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (101 votes), past polls