ltp has asked for the wisdom of the Perl Monks concerning the following question:
sub method {
my $self = shift;
Is deeply ingrained in memory of my fingers, however when writing some code for various getter methods, my subconscious predisposition for terseness shortened:
sub get_foo {
my $self = shift;
return $self->_bar(baz => 2, frob => 30);
}
To:
sub get_foo { return $_[0]->_bar(baz => 2, frob => 30) }
The question I have is; is using '$_[0]' rather than '$self = shift' considered bad form?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Brief OO question
by armstd (Friar) on Oct 05, 2011 at 02:51 UTC | |
|
Re: Brief OO question
by chromatic (Archbishop) on Oct 05, 2011 at 16:54 UTC | |
|
Re: Brief OO question
by Anonymous Monk on Oct 05, 2011 at 06:50 UTC | |
|
Re: Brief OO question
by zwon (Abbot) on Oct 05, 2011 at 11:09 UTC | |
by tospo (Hermit) on Oct 06, 2011 at 14:04 UTC |