where the first argument to the constructor (after the class name) is an object which isa-resolves to the package name.my $foo = Class->new( this => 2, that => 3 ); my $bar = Class::new( $foo => 4, that => 5 );
package Class; sub new { unshift @_, __PACKAGE__ unless $_[0]->isa(__PACKAGE__); # rest of code... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: OO Slip-up Preventor
by tye (Sage) on Jan 18, 2001 at 20:05 UTC | |
by japhy (Canon) on Jan 18, 2001 at 20:34 UTC | |
|
Re: OO Slip-up Preventor
by Anonymous Monk on May 28, 2002 at 23:26 UTC |