Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: Mouse as prelude to Moose?

by jasonk (Parson)
on Feb 05, 2009 at 21:11 UTC ( #741694=note: print w/ replies, xml ) Need Help??

in reply to Re: Mouse as prelude to Moose?
in thread Mouse as prelude to Moose?

By default Moose (and I'd assume also Mouse) will allow you to pass any keys you want to an object constructor. So what happens is just that the ks is being ignored. The reason it doesn't throw an error for an unknown key is so you can do something like this:

package Foo; use Moose; has 'number' => ( is => 'rw', isa => 'Num', ); sub BUILD { my ( $self, $args ) = @_; $self->number( $args->{ 'foo' } * 42 ); }

You can turn this behavior off for your own modules with MooseX::StrictConstructor.
We're not surrounded, we're in a target-rich environment!

Comment on Re^2: Mouse as prelude to Moose?
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-11-29 15:56 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls