Greetings,
I have a moose question. I'm still new to moose. Normally I would pass parameters to a new object thusly.
my $ob = MyModule->new( colour => $colour, shape => $shape, );
Suppose that colour and shape are arguments and that they are optional. It seems that if no argument is given via my program the value is ''. This seems to confuse my classes on the moose side where it fails to set the default. My thought was to build the parameter hash before hand so as to pass only the arguments that are defined.
if ( $colour ) { $param{'colour'} = $colour }; if ( $shape ) { $param{'shape'} = $shape }; my $ob = MyModule->new( %param );
I tried this but nothing seems to make it to moose. Am I on the right track? Is there better way?
Neil Watson
watson-wilson.ca
In reply to Passing params, as a hash, to moose by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |