in reply to Re: Static method vs virtual method
in thread Static method vs virtual method
Generally, static methods ignore the first argument because they already know which class they are in. new() is implemented by almost all packages as a static method.
Yet, because of inheritance and possibility of being called on behalf of other package, well-behaving new() shouldn't ignore the first argument. In simplified case like this:
sub new { my ($class, %opts) = @_; my $self = { %opts }; bless $self, $class; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Static method vs virtual method
by freonpsandoz (Beadle) on Oct 14, 2016 at 05:42 UTC | |
by choroba (Cardinal) on Oct 14, 2016 at 08:28 UTC |
In Section
Seekers of Perl Wisdom