Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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
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 romping around the Monastery: (5)
As of 2014-08-02 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls