Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Class::Methodmaker inheritance

by qq (Hermit)
on Mar 08, 2004 at 23:30 UTC ( #334970=note: print w/replies, xml ) Need Help??


in reply to Class::Methodmaker inheritance

It seems like your subclassing confusion got sorted out. Here is a snippet for 'required' arguments to constructors, using Class::MakeMethods. Check out the Examples about custom initialization for more ideas

package Foo; use Class::MakeMethods::Template::Hash ( 'new --with_init' => 'new', scalar => 'foo', ); sub init { my $self = shift; my %args = @_; die 'I need foo!' unless $args{ foo }; $self->foo( $args{foo} ); }

Basically the constructor hands off value initialization to an init method if asked to. It may be that Class::MethodMaker supports this kind of thing too - I'm not familiar with it.

qq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2023-09-30 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?