BTW, there'll be a new version of Class::Multimethods out in the next month or two that lets you define multimethods like they will (probably) be written in Perl 6:package MyClass; use Class::Multimethods; multimethod new =>('$') => sub { my ($class) = @_; bless { name => '', rank => '', cereal_number => '', }, $class; } multimethod new =>('$','$','$','$') => sub { my ($class, $name, $rank, $c_num ) = @_; bless { name => $name, rank => $rank, cereal_number => $cnum, }, $class; }
Damianpackage MyClass; use Class::Multimethods::Attributes; sub new :multi ($class) { bless { name => '', rank => '', cereal_number => '', }, $class; } sub new :multi ($class, $name, $rank, $c_num) { bless { name => $name, rank => $rank, cereal_number => $cnum, }, $class; }
In reply to Re: OO Perl: calling a constructor within a class
by Anonymous Monk
in thread OO Perl: calling a constructor within a class
by fx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |