Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Moose - ensuring a getter returns a number

by perl5ever (Pilgrim)
on Feb 17, 2011 at 20:40 UTC ( #888791=note: print w/ replies, xml ) Need Help??


in reply to Re: Moose - ensuring a getter returns a number
in thread Moose - ensuring a getter returns a number

Thanks for the idea.

Is there anything that can be done with Moose type constraints?


Comment on Re^2: Moose - ensuring a getter returns a number
Replies are listed 'Best First'.
Re^3: Moose - ensuring a getter returns a number
by stvn (Monsignor) on Feb 18, 2011 at 05:14 UTC

    Not likely, since Perl is so permissive about what is a number and what is a string, the Moose type constraint for numbers allows them to also be strings as well.

    The solution with the around is actually pretty good, or as another responder points out, make sure that the value is a number before it is actually added to your data object.

    -stvn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2015-09-01 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (17 votes), past polls