Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Passing Str or undef ?

by FunkyMonk (Chancellor)
on Apr 26, 2011 at 13:49 UTC ( [id://901350]=note: print w/replies, xml ) Need Help??


in reply to Passing Str or undef ?

Using MooseX::Declare you can...
use MooseX::Declare; class Foo { method baz(Str|Undef $x) { say $x // '[undef]'; } }; Foo->new->baz($_) for undef, "hi", [], {}; __END__ [undef] hi Validation failed for 'Tuple[Tuple[Object,Str|Undef],Dict[]]' with val +ue [ [ Foo=HASH(0x2645708), ARRAY(0x101e2... [+] Validation failed for 'Str' with value ARRAY(0x2105220) and Vali +dation failed for 'Undef' with value...

MXD uses MooseX::Method::Signatures so I guess you'll be able to adapt the code above.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-18 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found